I got usual macros as below:
#ifdef PLATFORM_WINDOWS
#ifdef BUILD_SHARED
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif
#else
#define API
#endif
(The lib compiles with /DBUILD_SHARED
)
Then I have a global union object which I want to export/import:
header file:
#ifdef __cplusplus
extern "C" {
#endif
//definition of union type
API extern union U global;
#ifdef __cplusplus
}
#endif
source file:
// include header
API union U global;
The lib compiles fine, but while linking an executable to it I get linker error unresolved external symbol _global
. I'm using MSVC (VS 2015). Not sure if C linkage has anything to do with it. I'm not even sure if it actually uses C linkage because Intellisense shows as __cplusplus
is not defined in header file quoted above.