• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: An Array of structs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >An Array of structs (From: John Love <email@hidden>)
 >Re: An Array of structs (From: Jeremy Pereira <email@hidden>)
 >Re: An Array of structs (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Apache Module
  • Next by Date: Re: Getting the path to an application with a launchDaemon
  • Previous by thread: Re: An Array of structs
  • Next by thread: Conversion of CFSocketCreateWithNative -> NSSocketPort
  • Index(es):
    • Date
    • Thread