c++ - Global variable dll export/import -
i got usual macros below:
#ifdef platform_windows #ifdef build_shared #define api __declspec(dllexport) #else #define api __declspec(dllimport) #endif #else #define api #endif
(the lib compiles /dbuild_shared
)
then have global union object want 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, while linking executable linker error unresolved external symbol _global
. i'm using msvc (vs 2015). not sure if c linkage has it. i'm not sure if uses c linkage because intellisense shows __cplusplus
not defined in header file quoted above.
Comments
Post a Comment