C++ and objective-c
Kevin Ingwersen
ingwie2000@googlemail.com
Wed Apr 30 16:10:00 GMT 2014
Thats old cake. Objective-C++ is exactly what you want. See?
— ObjC++
#include <iostream>
#import <Foundation/Foundation.h>
class DatValue {
public:
std::string oo;
};
@interface do_the : NSObject {}
+(void)talk:(std::string)that;
@end
@implementation do_the
+(void)talk:(std::string)that {
std::cout << "I am supposed to say: " << that << std::endl;
}
@end
int main() {
DatValue dv;
dv.oo="Derp!";
[do_the talk:dv.oo];
}
—
Note, this only works on Mac…the code, that is. I did not remember the exact contents of <objc/objc.h>, otherwise I would have just used the Gnu runtime. But basicaly, thats how it looks like. Make sure to save the file with .mm eding, and link to the runtime. I.e.:
$ g++ derp.mm -o derp -lobjc
will do.
Am 30.04.2014 um 17:55 schrieb Steven Boyls <sboyls@me.com>:
> I was reading on the gnustep site that soon gcc would be able to compile files that contained both objective-c and c++.
> What is the status of this?
> When will it be implemented.
>
> Regards,
>
> Steve
>
> Sent from my iPhone
More information about the Gcc-help
mailing list