RE: How to compile Objective-C code with GCC ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] För niXman
Skickat: den 18 januari 2013 21:49
Till: gcc-help@xxxxxxxxxxx
Ämne: Re: How to compile Objective-C code with GCC ?

ping?



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux