Reasonable static initialization assurance

corey taylor corey.taylor@gmail.com
Sat Sep 17 17:29:00 GMT 2005


Is there any reasonable manner to ensure a static object is
initialized before use without wrapping it in a getter/setter
function?

We are seeing some order issues show up on an OSX build (not linux though yet).

Take file.a and file.b:

file.a has a global variable of a table which accesses the static
System class methods for allocation and setup.

file.b has the System methods which all call an init method when first
called to make sure the system is setup right and find out what
version and computer is running.  This method accesses a static global
variable in file.b and seg faults.

Is there any way to ensure a static variable in file.b is initialized
before being used?

Corey



More information about the Gcc-help mailing list