I disagree with Chris Becke's point of view, seeing the benefits of his approach.
The disadvantage is that you cannot create libraries of utility objects because you are forbidden to share them through libraries.
Chris Solution Extension
How to make serial dll binaries in VS versions?
Your choice depends on how different the compilers are. On the one hand, different versions of the same compiler can handle data alignment in the same way, and thus you can identify structures and classes in your DLLs. On the other hand, you may not trust other library compilers or compilation options.
In the Windows Win32 API, they dealt with the problem through "handlers". You do the same:
1 - Never expose the structure. Print only pointers (i.e. void * pointer)
2 - Access to the structure data is carried out through functions , indicating the pointer as the first parameter
3 - this allocation / deletion data struct pointer is used through functions
This way you can avoid recompiling everything when your structure changes.
C ++ way to do this is PImpl. See http://en.wikipedia.org/wiki/Opaque_pointer
It has the same behavior as the void * concept, but with PImpl you can use both RAII and encapsulation, as well as the benefits of strong security. To do this, you need a compatible design (the same compiler), but not the same runtime or version (if the scenery is the same between versions).
Another solution?
Hoping to combine DLLs from different versions of compilers / compilers is either a recipe for disaster (as you explained in your question), or tedious, since you let go of most (if not all) C ++ solutions so that your code returns to basic C- encoding or both.
My decision:
1 - Make sure all your modules are compiled using the same compiler / version . Period.
2 - Make sure all your modules are compiled dynamically with the same runtime
3 - Make sure that you have an “encapsulation” of all third-party modules that you have no control over (it is impossible to compile with your compiler), as Chris Beck rightly explained in How to make serial DLL binaries for VS versions? .
Note that it is not surprising and not outrageous to claim that all modules of your application are compiled against the same compiler and the same version of the compiler.
Do not let anyone say that you mix compilers - that’s good. Is not. The freedom to mix the compiler for most people is the same freedom that you can enjoy jumping from the top of the building: you are free to do it, but usually you just don't need it.
My solution allows you to:
1 - export classes and, thus, create real, non-castrated, C ++ libraries (as you were supposed to do with Visual C ++ __declspec (dllexport), for example)
2 - assignment of the distribution of the transmission (what happens without your consent when using the allocation and / or release of the embedded code or STL)
3 - you should not annoy the problems associated with the fact that each module has its own version of the runtime (i.e., memory allocation and some global data used by the C or C ++ API)
Please note that this means that you should not mix the debug version of your modules with the release versions of other modules. Your application is completely debugged or completely freed.