What is __declspec and when do I need to use it?

前端 未结 6 1184
耶瑟儿~
耶瑟儿~ 2020-11-30 18:08

I have seen instances of __declspec in the code that I am reading. What is it? And when would I need to use this construct?

6条回答
  •  天命终不由人
    2020-11-30 18:24

    I know it's been eight years but I wanted to share this piece of code found in MRuby that shows how __declspec() can bee used at the same level as the export keyword.

    /** Declare a public MRuby API function. */
    #if defined(MRB_BUILD_AS_DLL)
    #if defined(MRB_CORE) || defined(MRB_LIB)
    # define MRB_API __declspec(dllexport)
    #else
    # define MRB_API __declspec(dllimport)
    #endif
    #else
    # define MRB_API extern
    #endif
    

提交回复
热议问题