• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Controlling initialization order
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Controlling initialization order


  • Subject: Re: Controlling initialization order
  • From: "b.bum" <email@hidden>
  • Date: Tue, 25 May 2004 22:34:21 -0700

On May 25, 2004, at 6:30 PM, David Catmull wrote:
> On May 25, 2004, at 11:05 AM, b.bum wrote:
>> The initialization order of C++ objects is unspecified across
>> "translation units" (effective oversimplification: across source
>> files).  That CodeWarrior (or other IDE/compiler/linkers) guaranteed
>> the order based upon link order is a feature that isn't within the
>> specification.
>
> I guess I've been living a sheltered life :)  I settled for
> restructuring my code.

It seems that many C++ programmers have been living such a life.   The
reality is that the initialization order is quite thoroughly
predictable given a controlled set of platform, linker, and compiler.
The problem is that the order is merely coincidence on that
predictability;  it is not defined to remain constant as any of the
generally constant variables change over time.

I have encountered many a codebase that worked just fine for years at a
time, only to break horrendously the first time it was used in an
"alien" environment or fashion.  It has cost many an hour of debugging
only to find that someone somewhere had forgotten that Class A really
needed to be initialized before Class B.   And, of course, the absolute
most funnest part of debugging the problem was often that the debugger
would cause the initialization order to change! (all sarcasm intended)

b.bum
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Controlling initialization order (From: David Catmull <email@hidden>)
 >Re: Controlling initialization order (From: "b.bum" <email@hidden>)
 >Re: Controlling initialization order (From: David Catmull <email@hidden>)

  • Prev by Date: Re: Routine viewing of specific values of a complex data structure in the debugger
  • Next by Date: Re: Code completion of member functions / attributes?
  • Previous by thread: Re: Controlling initialization order
  • Next by thread: C# in XCode .. can .NET help ?
  • Index(es):
    • Date
    • Thread