'dllimport' attribute only applies to variables, functions and classes warning even though applied to class function

I'm in the middle of a port to the newest c++ Builder 11 (Clang) compiler and I ran into a warning that I don't understand

The warning:

'dllimport' attribute only applies to variables, functions and classes

The simplified code:

class Test
{
   public:

   Test() ;

   int __declspec(dllimport) (*DllFunction)  (int a, int b) ;

} ;

And during construction (for instance) I load the dll and find a pointer for DllFunction

This is a function, so .. why the warning ? What am I not getting ?


As the error message says, dllimport cannot be used to import individual class methods. Only standalone variables and functions, and whole classes. However, dllimport is meant for static linking only, but you are using dynamic loading instead, so there is no need to use dllimport in this code at all.


You can't dllimport a member function without dllimport-ing the whole class - this is where your dllimport should be.