• 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: Help Mixing Objective-C & Objective-C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help Mixing Objective-C & Objective-C++


  • Subject: Re: Help Mixing Objective-C & Objective-C++
  • From: Greg Parker <email@hidden>
  • Date: Wed, 23 Feb 2011 17:44:21 -0800

On Feb 23, 2011, at 5:34 PM, Charles Srstka wrote:
> On Feb 23, 2011, at 2:35 PM, James Bucanek wrote:
>
>> It also occurred to me that if I'm careful, the Objective-C code doesn't really need any of the details of the instance variables in the Objective-C++ class:
>>
>> @interface MyCPPClass : NSObject
>> {
>> #ifdef __cplusplus
>>   @private
>>   SomeCPPClass *someCppObject;
>> #endif
>> }
>> - (void)doSomething;
>> @end
>
> Not a good idea. In the 32-bit runtime, this might cause problems with subclassing due to the fragile base class problem.

Absolutely. That's why the next line in James' post was:

>> So if the C code never accesses any instance variables directly, or **defines a subclass of this class**, or calculate the size of the object, etc., then it should function just fine in complete ignorance of its internal structure.


Unfortunately, I can't think of a clever way to explicitly enforce "no non-C++ subclasses" by causing a compiler error or something.


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

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: 
 >Re: Help Mixing Objective-C & Objective-C++ (From: James Bucanek <email@hidden>)
 >Re: Help Mixing Objective-C & Objective-C++ (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Help Mixing Objective-C & Objective-C++
  • Next by Date: Re: IBOutlet to different classes, conditional build
  • Previous by thread: Re: Help Mixing Objective-C & Objective-C++
  • Next by thread: Re: Help Mixing Objective-C & Objective-C++
  • Index(es):
    • Date
    • Thread