Re: Cocoa Classes from C++?
Re: Cocoa Classes from C++?
- Subject: Re: Cocoa Classes from C++?
- From: Bill Bumgarner <email@hidden>
- Date: Tue, 27 May 2008 20:59:17 -0700
On May 27, 2008, at 8:43 PM, Jens Alfke wrote:
This basically tells a white lie to any non-C++-savvy source file
that imports the header, telling them that MyCppClass* is just some
kind of pointer, and not to worry its pretty little head about
exactly what it is. This is safe because (a) all pointers are the
same size, so the ivar layout is correct; and (b) no one but
MyCppClass.mm can actually access the raw instance variable anyway.
Lieing to the compiler is a good way to get yourself in trouble. ;)
In this case, it will change the way that GC handles the pointer,
depending on how the class is compiled. GC is aware of the layout of
objects and will scan only the fields that are marked __strong or are
of an Objective-C object reference type.
So, depending on how exactly the class is compiled, you could end up
with executable context that sees the reference as scanned and one
executable context that doesn't.
Best to use a void* instead.
b.bum
_______________________________________________
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