0

When I want to create a .dll-File in Visual Studio (c++) I use the following code in the Header-File:

#ifdef MYPROJDLL_EXPORTS
#define MYPROJDLL_API __declspec(dllexport) 
#else
#define MYPROJDLL_API __declspec(dllimport)
#endif

I use "MYPROJDLL_API" as a macro to mark functions of the class that have to be exported. Visual Studio creates the definition of "MYPROJDLL_EXPORTS" automatically in the project settings. I ask myself why I have to create an if-statement because "MYPROJDLL_EXPORTS" is defined by Visual Studio on build by itself, so that the else-branch is never triggered on building.

Moreira
  • 576
  • 2
  • 8
Rocco
  • 33
  • 1
  • 6
  • 2
    Have you read documentation? – David Heffernan May 07 '16 at 20:25
  • Yes. "MYPROJDLL_EXPORTS" is only defined during compiling. When another program use the .dll, the else-branch ist triggered. But if I use only dllexport, my program is also compiled fine and runs. – Rocco May 07 '16 at 21:22

0 Answers0