• 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: Mixing CPP and Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixing CPP and Obj-C


  • Subject: Re: Mixing CPP and Obj-C
  • From: Dave Carrigan <email@hidden>
  • Date: Thu, 26 Aug 2010 09:17:52 -0700

On Aug 26, 2010, at 9:11 AM, email@hidden wrote:
> I want to add Obj-C to classes in a  CPP static library that is used by Mac and Windows apps. I have set the compile type to cpp.objc so that the file extension can remain .cpp and compile on Windows.  I am #ifdef'ing functions that use Cocoa.
>
> My question is memory management. Should functions allocate/release auto release pools?


Autorelease pools are not scoped to any particular class or function, so probably not, unless you're using the library in an application that doesn't have an autorelease pool, which would be pretty rare. You would also need to create a new pool in any thread other than the main one, and drain it at thread exit.

If an object gets autoreleased and there is no autorelease pool in place for it, you'll see a big warning in the console, so just look for those. If you don't see one, then you're OK.

--
Dave Carrigan
email@hidden
Seattle, WA, USA

_______________________________________________

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

  • Follow-Ups:
    • Re: Mixing CPP and Obj-C
      • From: email@hidden
References: 
 >Mixing CPP and Obj-C (From: email@hidden)

  • Prev by Date: Mixing CPP and Obj-C
  • Next by Date: Re: Mixing CPP and Obj-C
  • Previous by thread: Mixing CPP and Obj-C
  • Next by thread: Re: Mixing CPP and Obj-C
  • Index(es):
    • Date
    • Thread