Search code examples
declspec

Warning C4091: ' __declspec(dllexport)'


I have the following code where I am trying to export a function called "Interface_API" out of my dll.

#ifdef INTERFACEDLL_EXPORTS
#define UserApp_API __declspec(dllexport);
#else
#define UserApp_API __declspec(dllimport);
#endif

UserApp_API int Interface_API(int *, int *, int *);

When I compile this code it gives the following warning and the function is not getting exported.

warning C4091: ' __declspec(dllexport)' : ignored on left of 'int' when no variable is declared

When I change the declaration as given below I don't get the warning and it exports properly.

__declspec(dllexport) int Interface_API(int *, int *, int *);

I am little confused because I have used it in different dll and it works fine. Any clue?


Solution

  • #define UserApp_API __declspec(dllimport);
                                             ^ Semicolon.