Friday, 20 April 2012

GNUstep/Objective-C - First Contact

I have been creating little Objective-C Programs on My Windows Machine (It's not really mine,I would never have a windows PC) just to get the compilation working, I started with Installing GNUstep - very easy:

Install all of these bits:
  • GNUstep MSYS System
  • GNUstep Core
  • GNUstep Devel
Then I created a simple program in a file called hello.m:



#import <stdio.h>
int main(int argc, const char *argv[]){
     int i = 1;
     int *iptr;
     iptr = &i;
     *iptr = 2;
   
     printf("result %d",*iptr);
     return 0;

}


Question:  Why isn't it easier to format code in this blog?


Anyway, this is a fairly simple piece of code, doesn't do much, a little with pointers (which as a Java developer I never had to worry about, and printf).  It compiles, it runs, it displays data!  easy!  to compile I use this line: 
 g++ hello.m -o hello 
To run it I type:
 ./hello.exe  and the output  is: result 2 
Simples, works like a charm, step one complete Big tick in the box

No comments:

Post a Comment