Re: Using Objective-C object in C++ source
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