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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to