I create a dll project in vs2015, include 2 modules (2 projects)
project 1
in testDLLint.h
ifdef TESTDLLINT_EXPORTS
define TESTDLLINT_API __declspec(dllexport)
else
define TESTDLLINT_API __declspec(dllimport)
endif
class TESTDLLINT_API CtestDLLint {
public:
CtestDLLint(void);
public:
int m;
};
extern __declspec(dllexport) int myInt;
extern __declspec(dllexport) CtestDLLint myInst;
in file1.c
include "testDLLint.h"
__declspec(dllexport) int myInt; = 0;
__declspec(dllexport) CtestDLLint myInst;
TESTDLLINT_API int fntestDLLint(void) {
return 42;
}
CtestDLLint::CtestDLLint() {
return;
}
project 2
file1.c
pragma comment(lib,"../../Debug/testDLLint.lib")
extern __declspec(dllimport) int myInt; // good
extern __declspec(dllexport) CtestDLLint myInst;
int main(){
myInt = 10; // access myInt from module 1 is ok
myInst.m = 10; // wrong
}
my problem is
1) accessing myInt from dll of module 1 is ok
2) acessing class instance myInst from dll of module 1 is not ok
for accessing class's instance from dll, is it possible? if possible, how to do it ?
thanks a lot