Macro in class definition

前端 未结 1 680
情深已故
情深已故 2020-12-20 10:56

class is defined using Macro. Not sure what is the significance of MACRO DEBUG_API here. [I understand #define is used to turn on or off some specific set of code.] But b

相关标签:
1条回答
  • 2020-12-20 11:33

    When defining this macro, you can choose attributes that will be applied to the class. These can be standard or compiler-specific attributes.

    Your particular example is most probably an instance of the usual pattern for DLL headers under MSVC. Depending on a compile-time switch, DEBUG_API will be set to either :

    • __declspec(dllexport), which will make MSVC generate a .lib file containing the class' thunk; this is used when compiling the library as a DLL;
    • __declspec(dllimport), which will make MSVC link against the thunk generated above; this is used when linking with the DLL;
    • Nothing, which won't alter the behaviour of the class. This is used to link statically against the library.
    0 讨论(0)
提交回复
热议问题