• 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: Andreas Grosam <email@hidden>
  • Date: Thu, 24 Feb 2011 12:53:46 +0100

On Feb 24, 2011, at 10:43 AM, Gwynne Raskind wrote:

> You can use protocols alone to do object creation with a little runtime trickery. I'm quite fond of this small set of language "extensions":
>
> <http://code.google.com/p/libextobjc/>

I would really prefer that this "extension" below will work soon:    ;)


=== File: MyClass.h - Note this is an Objective-C++ header!!  *)
#import <Foundation/Foundation.h>

@interface MyClass : NSObject
- (id) init;
@end


=== File: MyClass.mm

#import "MyClass.h"
#include "Foo.hpp"    // C++ class definition

@interface MyClass ()
-(void) privateMethod;
@end

@implementation MyClass {
    Foo* privateIvar;         // <== ivar declaration where it belongs to (IMHO)
}

- (id) init {
    self = [super init];
    if (self != nil) {
        privateIvar = new Foo();
    }
    return self;
}
- (void) dealloc {
    delete privateIvar;
    [super dealloc];
}
- (void) privateMethod {
}
@end


*) Using an Objective-C++ header file in an Objective-C module may require some additional ’extern "C"’ declarations.

Unfortunately, this doesn't compile yet. This would require that LLVM can be used for Objective-C++ modules and that the compiler flag -fobjc-nonfragile-abi2 can be passed to the compiler driver._______________________________________________

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: Help Mixing Objective-C & Objective-C++
      • From: Greg Parker <email@hidden>
References: 
 >Help Mixing Objective-C & Objective-C++ (From: James Bucanek <email@hidden>)
 >Re: Help Mixing Objective-C & Objective-C++ (From: Lee Ann Rucker <email@hidden>)
 >Re: Help Mixing Objective-C & Objective-C++ (From: Andreas Grosam <email@hidden>)
 >Re: Help Mixing Objective-C & Objective-C++ (From: Gwynne Raskind <email@hidden>)

  • Prev by Date: Loading SampleHardWarePlugin problem
  • Next by Date: dynamic binding in initializers
  • Previous by thread: Re: Help Mixing Objective-C & Objective-C++
  • Next by thread: Re: Help Mixing Objective-C & Objective-C++
  • Index(es):
    • Date
    • Thread