Macro for dllexport/dllimport switch

One another option:

Use the default defined macro local to the project.

You can see the default defined macros local to the project in the below location:

Properties -> C/C++ -> Preprocessor -> Preprocessor Definition.

Example:

Suppose your Project Name is: MyDLL

Default Macro Local to that project: MYDLL_EXPORTS

 #ifdef  MYDLL_EXPORTS 
    /*Enabled as "export" while compiling the dll project*/
    #define DLLEXPORT __declspec(dllexport)  
 #else
    /*Enabled as "import" in the Client side for using already created dll file*/
    #define DLLEXPORT __declspec(dllimport)  
 #endif

Leave a Comment