[Scummvm-devel] merged Dragon History into trunk

Max Horn max at quendi.de
Sun Sep 27 22:08:41 CEST 2009


Hi there,

using global variables of a non-POD types (e.g. a class/struct with a  
non-trivial constructor) is in general not portable and won't work on  
many systems -- as observed in this case. Most commonly, these break  
because the constructors are not called at all or are called  
"incorrectly".

Short and simple solution to make the code portable: Don't use them.  
So e.g. instead of having

   Common::String g_someGlobalString;

you should consider alternatives. The best is to move that object as a  
member into another class, e.g. your Engine subclass. Another  
alternative is to replace it by

   Common::String *g_someGlobalString = 0;

and then in init the variable in a suitable place, e.g. your Engine  
constructor.


Cheers,
Max




More information about the Scummvm-devel mailing list