RE: [GD-Windows] STL Containers and __declspec(export/import)
Brought to you by:
vexxed72
From: Vasco L. <va...@kr...> - 2005-02-07 00:39:52
|
At 00:47 07.02.2005, you wrote: >Your guess is correct. > >Exporting the STL containers is a Bad Thing(tm). > >Implementations of the STL are not necessarily binary compatible. There is >no convenient way to translate between different implementations, so if the >DLL uses a different version than your executable, the objects will differ >and your program will fail. afaik this is a general problem of c++ (no general C++ ABI, see also http://aegisknight.org/cppinterface.html ), so in principle the same applies to normal c++ objects. >Vectors are a special case. The latest versions of the C++ standard have a >guarantee that vectors are contiguous, and all major implementations before >that guarantee also have that behavior, so passing vectors around as general >arrays can be done safely. > >I seem to remember also that the VC++ 7.1 uses local storage in the >implementation, so in that case, even moving between the same implementation >would fail if you crossed EXE/DLL boundaries. Not if you link all your modules to the DLL runtime, again all with the same version. I use lots of stl and boost with my DLLs. As long as you make sure that all components are compiled with same compiler (+ same version) and linked with the runtime DLL it works without any problems. Otherwise it really gets involved: only C functions and pure abstract C++ types allowed and seperated memory managment between modules. Vasco |