Using Visual Studio 2015 Community Edition.
I have a global object instantiated in a library. That object contains a vector of strings. That global object is accessed and used correctly without problems except under the following condition.
If a portion of application code not in the library throws an exception, the exception processing calls into that object, to access the vector of strings for reporting purposes.
catch (Exception & e) {
dwl::Globals * p = gDwlGlobals; wStringStream s; s << p; OutputDebugString(s.str().c_str());
const Strings & strings = gDwlGlobals->strings(); wString str = strings[Strings::Error_Programming]; ...
The
OutputDebugString
gives the same address for the global as the global showed during instantiation.
At (*A*) - In the debugger, the global address shows correctly on this line, and the '
strings
' vector shows 79 elements in it through the dropdowns.
At (*B*) - The
strings
vector is now empty! And the
enum
offset throws an exception in my exception.
Any pointers?
What I have tried:
Everything I can think of except eliminating the library approach and seeing if making the solution into one project fixes it. (I think it will fix it, because I don't remember this error occurring before splitting it apart into a library. But I'd like to know why this isn't working.)
OK, I just tried eliminating the lib approach. As suspected, the error goes away. So the problem must be that the
extern
definitions are somehow not the same in the library and the non-library code, even though there is only one true non-extern definition. Any pointers on syncing lib pointers to the main application?