• 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: Using Objective-C object in C++ source
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Objective-C object in C++ source


  • Subject: Re: Using Objective-C object in C++ source
  • From: Christopher Corbell <email@hidden>
  • Date: Thu, 14 May 2009 21:58:32 -0700



On Thu, May 14, 2009 at 8:53 PM, Michael Crawford <email@hidden> wrote:
> In 32-bit, Mac code, yes, that is the case. However, in 64-bit Mac
> code and iPhone code, C++ exceptions and Objective-C exceptions are
> one-in-the-same.

That would seem to me to make the problem worse, in that it could
cause the 64 and 32 bit versions of one's application to have
incompatible source code.


The exception problem's really problem of how the different models unwind the stack.  Since ye olde Objective-C had its particular reference/allocation scheme it (arguably) didn't need to rely on unwinding the stack to dispose of objects at exception time the way C++ does - this means that C++ objects on the stack might not get their destructors called if they get jumped over by an uncaught Objective-C exception, which is at best a memory leak.

While you might feel the 64/32 divide makes things worse I'm at least thankful that Objective-C is moving away from the old exception model - I'm assuming eventually the old Objective-C exceptions will be completely deprecated but these kinds of changes don't happen overnight.

In general I've dealt with this by keeping Objective-C code and C++ code as segregated as possible and making sure I handle Objective-C exceptions as early as possible whenever they're likely to be thrown.

I have to say in general Objective-C++ is awesome and mostly seamless - if you want pain try C++/CLI .NET. :-)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Using Objective-C object in C++ source (From: "K. Chen" <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: Dave Carrigan <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: Andreas Grosam <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: "K. Chen" <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: Shawn Erickson <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: Michael Crawford <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: Clark Cox <email@hidden>)
 >Re: Using Objective-C object in C++ source (From: Michael Crawford <email@hidden>)

  • Prev by Date: Re: Using Objective-C object in C++ source
  • Next by Date: Re: date-time info at compile time
  • Previous by thread: Re: Using Objective-C object in C++ source
  • Next by thread: Re: Using Objective-C object in C++ source
  • Index(es):
    • Date
    • Thread