Reputation: 11
I need to share a variables (1000s) between 2 C++ Dlls. How should I do that?
MyVariables.Dll
contains:
int a = 0;
ModifyMyVariables.Dll
contains:
extern int a;
a++;
// do more stuff with a;
What am i supposed to write in the following files?
myvariables.h
myvariables.cpp
ModifyMyVariables.h
ModifyMyVariables.cpp
Upvotes: 0
Views: 4046
Reputation: 6314
You can share data between images (EXE, DLL...) using several fundamental mechanisms (using extern does not work to share data - it only instructs the linker and not the loader!)
In your case, I would use the sections. This works pretty good. You must, of course, take care of the synchronisation when accessing (writing) these data from both sides.
Upvotes: 1