This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Reasonable static initialization assurance
- From: corey taylor <corey dot taylor at gmail dot com>
- To: gcc-help at gnu dot org
- Date: Sat, 17 Sep 2005 12:15:54 -0500
- Subject: Reasonable static initialization assurance
- Reply-to: corey dot taylor at gmail dot com
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