Re: NSAutoreleasePool and static data member constructors
Re: NSAutoreleasePool and static data member constructors
- Subject: Re: NSAutoreleasePool and static data member constructors
- From: "Clark Cox" <email@hidden>
- Date: Wed, 10 Oct 2007 15:19:43 -0700
On 10/10/07, Uli Kusterer <email@hidden> wrote:
> Am 10.10.2007 um 16:28 schrieb Clark Cox:
> > but never raw pointers. Raw pointers to C++ objects should not be used
> > as Objective-C instance variables. Additionally, except for simple,
> > transient Obj-C objects, the C++ objects should be "owned" by the
> > Objective-C objects, not the other way around.
>
> Errr... I'm not sure whether that was a 10.3-only limitation, but I
> distinctly remember that Objective C did not call C++ constructors
> for its instance variables. The compiler option to activate this has
> been around for a while, but AFAIK the C++ runtime currently shipping
> with 10.4 doesn't support that option yet.
10.4 most certainly supports this. (My last employer's flagship
project was a large medical application written in Objective-C++ that
ran on Tiger). Of course, we controlled the hardware and OS as well as
the software itself, so we didn't have to worry about running on older
OSes.
> So, I don't think you can
> use C++ smart pointers and the likes as instance variables. You /have
> to/ use pointers and new and delete them properly.
Smart pointers take care of this for you.
The rest of your e-mail is spot on:
Global autorelease pool or pool created before main() - bad idea
Throwing exceptions across language boundaries - bad idea
--
Clark S. Cox III
email@hidden
_______________________________________________
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