Re: An Array of structs
Re: An Array of structs
- Subject: Re: An Array of structs
- From: Jens Alfke <email@hidden>
- Date: Fri, 27 Nov 2009 22:55:52 -0800
On Nov 27, 2009, at 7:48 AM, Alastair Houghton wrote:
> You *can* have non-constant elements in struct initialisers in C, *but* only in a context where there is code that will execute at runtime.
C++ eliminates most of these restrictions, btw. And you can make your code C++ simply by changing the suffix from ".m" to ".mm".
That said, I've found that putting Obj-C object pointers in C/C++ structs can be very painful, due to refcounting issues. It's easy to copy the structs around, but doing so doesn't bump the refcounts of the objects they point to, so you can end up with dangling pointers to dealloced objects. (There are ways around this but they involve building C++ smart pointer classes to manage the Obj-C refcounts...)
—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