Search code examples
objective-cwindowsgnustep

Windows and objective-c


I want to start learning objective-c with book: Programming in Objective-C (4th Edition) . I working on Windows xp. To compile objective-c programs I install GNUstep and when I type this example what I found in some tutorial:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSLog (@"hello world");
    [pool drain];
    return 0;
}

Its all works fine. But when I try to type first example from this book:

#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
    NSLog (@"Programming is fun!");
}
return 0;
}

I get many errors:

What I get ib console

Do anyone know what I dooing wrong? Thanks for any help.


Solution

  • This is because @autoreleasepool is a new feature introduced with the LLVM compiler, so basically your compiler won't understand how to process this. When Apple introduced ARC, this was a required change in the language and so it's now the standard way of creating autorelease pools.