Re: Xcode 5 & Obj-C++
Re: Xcode 5 & Obj-C++
- Subject: Re: Xcode 5 & Obj-C++
- From: Jens Alfke <email@hidden>
- Date: Thu, 30 Jan 2014 13:26:59 -0800
On Jan 30, 2014, at 4:32 AM, Jean-Daniel Dupas <email@hidden> wrote:
> It is barely possible to create a stable ABI in C++. This language suffers all possible form of fragile base class problem:
> Add a new ivar, all subclasses and stack allocated objects are broken.
> Add a new virtual method, you break all virtual subclasses.
Exactly. Also, the use of templates or inline methods in library classes will cause library code to get built into the calling app at compile time. After that, the library has to be very careful not to break compatibility with such code to avoid breaking the app. A typical obvious example is changing the implementation of an inline method; newly compiled apps will get the new behavior but existing apps will keep the old behavior since the inlined code is in the app not the library. That's bad news if the old inline method accesses private state of the old version of the class that no longer exists in the same form in the new version.
It is possible to create binary-compatible C++ APIs but you have to be very, very careful — generally there are a lot of rules about the use of inlines and templates; you have to add placeholder data members and virtual methods to classes to reserve room for future expansion, etc.
—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