Reputation: 1855
So, based on instructions from this site, I downloaded the GNUStep Windows Installer from the GNUStep website
I then proceeded to install the stable versions of the following in this order:
GNUstep MSYS System
GNUstep Core
GNUstep Devel
I then write up the code below:
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *funnyWords = @[@"Schadenfreude", @"Portmanteau", @"Penultimate"];
for (NSString *word in funnyWords) {
NSLog(@"%@ is a funny word", word);
}
[pool drain];
return 0;
}
To compile the code, I tried using this command:
$ gcc `gnustep-config --objc-flags` -o hello hello.m -L C:/GNUstep/GNUstep/Syst
em/Library/Libraries -lobjc -lgnustep-base
While that was successful for other code I'd written up, this time it gave me these errors:
hello.m: In function 'main':
hello.m:7:23: error: stray '@' in program
hello.m:7:41: warning: left-hand operand of comma expression has no effect [-Wun
used-value]
hello.m:7:57: warning: left-hand operand of comma expression has no effect [-Wun
used-value]
hello.m:7:73: error: expected ':' before ']' token
I believe the first error(stray '@') could be due to an older compiler, but I have no idea about the other errors. I looked up the errors, but none of the solutions pertained to my situation. Can anyone help out a Windows Objective-C compiling coder?
Upvotes: 1
Views: 411
Reputation: 727047
This is the new syntax that has been introduced in llvm:
NSArray *funnyWords = @[@"Schadenfreude", @"Portmanteau", @"Penultimate"];
Check the document for other examples of the new syntax, which is defined for dictionaries and numeric literals.
The old syntax for the same is
NSArray *funnyWords = [NSArray arrayWithObjects:@"Schadenfreude", @"Portmanteau", @"Penultimate", nil];
Please note the nil
at the end, it is important to add it there for the old API to know when to stop.
The remaining errors about the comma operator are a result of the same "misunderstanding" of the new syntax.
Upvotes: 1