Reputation: 6028
I'm trying to create an Objective-C string using the '#' and '##' operators. I've written the following macros:
#define OBJCKEY(p, s) p ## s
#define KEY(k) OBJCKEY(@, #k)
Which I'm trying to use in a function in the following way:
NSString *key = KEY(EnumValue1);
But Xcode reports the following error:
Pasting formed '@"EnumValue1"', an invalid preprocessing token
Any idea on how to fix this?
Note: I'm using the LLVM compiler.
Upvotes: 3
Views: 1292
Reputation: 86651
Any idea on how to fix this?
Is there anything wrong with
NSString* key = @"EnumValue1";
Or how about
#define KEY(k) (@#k)
NSString* key = KEY(EnumValue1);
Upvotes: 3