Re: Global and Static Variable initialisation Problem on MAC-OSX 10.3.3 & GCC 3.3 ........
Re: Global and Static Variable initialisation Problem on MAC-OSX 10.3.3 & GCC 3.3 ........
- Subject: Re: Global and Static Variable initialisation Problem on MAC-OSX 10.3.3 & GCC 3.3 ........
- From: Steve Checkoway <email@hidden>
- Date: Mon, 6 Feb 2006 13:15:33 -0800
On Feb 6, 2006, at 10:20 AM, Cliff Russell wrote:
Gaurav,
Generally getting global and static variables to work correctly is
relatively straight forward. Can you post some code snippets
showing the general organization of the classes and object you are
having trouble with, and perhaps someone on the list can help.
The only things that I can think of that could cause the problems
your seeing are, either a misunderstanding of how global and static
variables work. Or, you in your code you have one or more global or
static variables that depend on other global/static variables being
initialized. Some compilers allow you to control the order that
globals and statics are initialized, I don't know if gcc is one of
those compilers. Typically, the safest route is to write your code
in such a way that the order that global and statics are
initialized isn't important.
C (and C++) offer no guarantees that about the order that global
variables are initialized other than constant init will happen before
nontrivial ctors (for c++). Relying on the order is a mistake and
your code _will_ break.
- Steve
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden