Can't compile objective c in linux -


i'm trying objective c, don't have mac trying work on linux. found these 2 articles talk compiling objective c on linux: this one and one

ok, forgot don't want use gnustep, seems dead , don't want cocoa framework, objective c syntax , c standard library. can't compile code without gnustep!

if try compile code:

#import <objc/object.h> #import <stdio.h>  @interface number: object { @public     int number;  }  - (void)printnum;  @end  @implementation number: object   - (void)printnum {     printf("%d\n", number); }  @end  int main(void) {     number *mynumber = [number new]; // equal [[number alloc] init]      mynumber->number = 6;      [mynumber printnum];      return 0; } 

i segmentation fault, because there's no init nor alloc methods. , if don't inherit object, so:

#include <stdio.h> // c standard io library (for printf) #include <stdlib.h> // c standard library // interface @interface test  -(void)sayhello :(char *)message; @end  // implementation @implementation test  -(void)sayhello :(char *)message {   printf("%s", message);  }  int main(int argc, char *argv[]) {  test *test = [[test alloc] init];  [test sayhello:"hello world"]; } 

i bus error. seems way create interfaces , implement them inheriting nsobject. how can fix this?

by way, i'm using gcc -lobjc flag (with gobjc)

edit: ok, have create root object myself if don't want use framework. how can this? imagine it's malloc , free in init , release methods, i'm not sure. how can this?

that's not how objective c works. need runtime, i'm afraid. many of bits of objective c happens @ run- rather compile-time. if take away library, there's not lot left.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -