Re: Is there a pattern for creating an object with global scope?
Re: Is there a pattern for creating an object with global scope?
- Subject: Re: Is there a pattern for creating an object with global scope?
- From: Jens Alfke <email@hidden>
- Date: Sat, 13 Apr 2013 22:04:10 -0700
On Apr 13, 2013, at 10:02 PM, Allan Odgaard <email@hidden> wrote:
>> C++ static initializers are evil, though, at least the ones that run code. They run super early, in an undefined order, with no way to specify dependencies between them; so if you’re not careful they can slow down launch and/or cause weird nondeterministic bugs.
>
> That would be when declared in the file scope. You can give them function scope which means they are not initialized before entering the function
Correct — and actually the way I fixed most of those static variable initializers [in Chrome btw] was to move them inside the functions that used them (or wrap them in functions.)
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden