Information
The following warning:
LINK : warning LNK4039: section '.SHARED' specified with /SECTION option does not exist
always occur whenever I try to store a vector in a data segment of a dynamic link library in C++.
For an example:
#include <vector>
struct Obj {
unsigned int A;
unsigned int B;
bool C;
std::vector< unsigned char > D;
};
#pragma data_seg( ".SHARED" )
std::vector< Obj > Objects;
#pragma data_seg()
#pragma comment ( linker,"/section:.SHARED,RWS" )
However, if I try to store a simple variable, there will be no warnings upon compilation. Like this:
#pragma data_seg (".SHARED" )
int SimpleVariable = 0;
#pragma data_seg()
I am not absolutely positive but, I believe the warning was caused by not initializing the vector? If so, how could we initialize a vector that will be stored within the data segment?
I have another question, is this a terrible idea to store a vector in the data segment within a DLL?
My Goal
I am trying to share the content of a vector within a DLL, which will be loaded into several different processes.
Like this:
process_1.exe
- example.dll -| * access the same vector (SomeVector) as
| example.dll within process_2
|
std::vector SomeVector; // vector in example.dll
|
process_2.exe | * access the same vector (SomeVector) as
| example.dll within process_1
- example.dll -|