This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]