This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: How to compile Objective-C code with GCC ?
- From: Ãke Forslund <aforslund at lasermaxroll dot se>
- To: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 21 Jan 2013 13:04:11 +0000
- Subject: RE: How to compile Objective-C code with GCC ?
I'm not an expert on Objective-C (in fact I haven't worked with it at all) so take my advice with a grain of salt. I think your hello world test is a bit over complicated, I tried this example (found on Swedish Wikipedia):
#import <stdio.h>
#import <objc/Object.h>
@interface MyClass : Object {
}
- (void)world;
@end
@implementation MyClass
- (void)world {
printf("hello, World!\n");
}
@end
int main() {
id hello = [MyClass new];
[hello world];
return 0;
}
I compiled with gcc hello.m -lobjc -o hello
This worked with no warnings and printed "Hello World!" as expected. (I must admit that my gcc is somewhat old 4.4.5)
/Ãke
Ãke Forslund
Lasermax Roll Systems
Tel: +46 (0) 372-25639
-----Ursprungligt meddelande-----
FrÃn: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] FÃr niXman
Skickat: den 18 januari 2013 21:49
Till: gcc-help@gcc.gnu.org
Ãmne: Re: How to compile Objective-C code with GCC ?
ping?