I get following error with following Objective-C code, while trying to compile it with clang.
Obj-C Code:
// first program example
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
NSLog (@"Programming is fun!");
}
return 0;
}
Error message:
main.m:6:5: error: unexpected '@' in program
@autoreleasepool {
^
main.m:7:38: error: extraneous ')' before ';'
NSLog (@"Programming is fun!");
^
main.m:7:16: warning: expression result unused [-Wunused-value]
NSLog (@"Programming is fun!");
^~~~~~~~~~~~~~~~~~~~~~
main.m:9:5: error: expected identifier or '('
return 0;
^
main.m:10:1: error: expected external declaration
}
^
1 warning and 4 errors generated.
I can compile without error within XCode.
Clang info:
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix
You need clang v3.0 or greater to use
@autoreleasepool.