I encountered a big gotcha with DLLs today, i have googled and failed to see any good explanation of appropriate practices for fixing it, so here goes:
I have a DLL with alot of functionality in it, one of these pieces of functionality is the implementation of a class called Path. Following a tutorial i found on a good practice for DLLs, i have a 'parallel' project that provides IPath, this project builds to a static lib and is linked in other DLL projects so that they can use the interface. It is also linked in to the test application.
Typical usage to get a path is like this:
IPath* pPathObject( GetDLLInterface()->CreatePath( "some path" ) );
Now IPath has a static std::map in it, this map stores symbols and replacement values, so you can do:
IPath::AddSymbolSubstition( "#SomeBasePath#", "C:/ActualPath" );
So then whenever you use that in a path it replaces it and you get the relative look up. The problem is, if i populate the map using AddSymbolSubstition (which is a static method populating a static object) in say WinMain and then use the IPath class within another DLL, wherever it is used that ISN'T where i initialised the map i don't have the entries i populated it with from WinMain.
Now i understand why this is, but i am strugging to think of a suitable way to circumvent this. Is this simply a case of DON'T DO THIS?
Any tips?