Re: Automagic instantiation of singletons? (Christian Brunschen)
Re: Automagic instantiation of singletons? (Christian Brunschen)
- Subject: Re: Automagic instantiation of singletons? (Christian Brunschen)
- From: Scott Ribe <email@hidden>
- Date: Sat, 19 Nov 2005 07:44:14 -0700
- Thread-topic: Automagic instantiation of singletons? (Christian Brunschen)
> The common way in C++ for instantiating singletons is
That's a lousy way to do it in C++, because you have no portable and
reliable way to control the order of instantiation, so you have to make
*sure* that there is *no* dependency anywhere between any 2 singletons,
otherwise you have a situation where even just a minor version bump of your
current tools can create a hard crash.
It's even worse in Objective-C++, since the C++ statics may be constructed
before the Cocoa runtime is completely up, and may be destructed after it is
at least partially torn down. I'm not clear on the specifics of that, but I
can tell you that using this idiom with C++ classes that interact with Cocoa
objects can lead to hard to track down crashes during application exit. It
may work perfectly well now, but there's no guarantee that it will continue
to work.
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 665-7007 voice
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden