How to share data between 2 dlls
-
-
Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance
Is How To Share Data Between Different Mappings of a DLL[^] helpful?
-
Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance
This is quite a complicated thing and there are may ways to do it and many pitfalls. If your not sure how to do this (and perhaps even if you are) perhaps it's best to use an existing library such as Boost.Interprocess[^].
Steve
-
Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance
Vijjuuuuuuuuu........... wrote:
Using pragma Data section or using Memory map files ?
If both A.dll and B.dll are in same process, you dont need to share it using #pragma . Just declare the variable as global and export it in the A.dll. Also you please note the below two points 1. Sharing the data segments using #pragma is used to share a data in a dll across multiple process. Not between two dlls in same process or multiple process. 2. You will not be able to share a map using shared section, because the map will be holding pointers to many dynamically allocated memories, which is valid only in corresponding process. Trying to access it from another process result in access vialotion.
nave [OpenedFileFinder]
-
Vijjuuuuuuuuu........... wrote:
Using pragma Data section or using Memory map files ?
If both A.dll and B.dll are in same process, you dont need to share it using #pragma . Just declare the variable as global and export it in the A.dll. Also you please note the below two points 1. Sharing the data segments using #pragma is used to share a data in a dll across multiple process. Not between two dlls in same process or multiple process. 2. You will not be able to share a map using shared section, because the map will be holding pointers to many dynamically allocated memories, which is valid only in corresponding process. Trying to access it from another process result in access vialotion.
nave [OpenedFileFinder]