I have a regular MFC application from which I want to export a variable and use it in a dll. Here is summary of declarations/definitions in exe/dll which should like here.
__declspec(dllexport) BOOL g_status; // In EXE
__declspec(dllimport) BOOL g_status; // in DLL
The linker error is following which seems to indicate it can't find due to name mangling?
error LNK2001: unresolved external symbol "__declspec(dllimport) int g_status" (__imp_?g_status@@3HA)
Then I tried this combination adding extern "C"' to declaration in dll but it doesn't work because if I use C decorations on dll, the same has to be done on exe side as well but using 'extern "C"
on exe side actually forces it to be become declaration!
__declspec(dllexport) BOOL g_status; // in EXE
extern "C" __declspec(dllimport) BOOL g_status; // in DLL
Linker Error below:
error LNK2001: unresolved external symbol __imp__g_status
I am a bit lost. I see a lot of examples with functions but not many with variables, how to export them and if name decorations are still in play?