Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / December 2005



Tip: Looking for answers? Try searching our database.

Global Initialization Order

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steve@walkereffects.com - 16 Dec 2005 19:39 GMT
I'm having a problem with the order of initialization of global objects
within my project. All my source is in C++ and I'm using Xcode 2.2.

I have a class which defines only static members and methods. All the
declarations are made in the header and the definitions in the cpp
file. However at execution time, it turns out that one of the static
methods is called before the static members have been initialized. Is
there a way I can force the class members to be initialized before it
is used by other global objects? I tried reordering the Compile
Sources, but it did not have any effect.

I hope I'm asking the right question. Thanks for any help.

Steven Walker
Ben Artin - 16 Dec 2005 20:50 GMT
> I'm having a problem with the order of initialization of global objects
> within my project. All my source is in C++ and I'm using Xcode 2.2.
[quoted text clipped - 6 lines]
> is used by other global objects? I tried reordering the Compile
> Sources, but it did not have any effect.

Depending on order of static initializers is a bug in your code. You should read
Item 26 in Meyers' "More Effective STL" for ideas on how to address this
problem.

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

steve@walkereffects.com - 16 Dec 2005 22:51 GMT
Thanks, I got it fixed.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.