Reputation: 1841
In the "Apple LLVM 7.0 - Preprocessing" section under the "Build Settings" tab, I've defined a Preprocessor Macros as:
HUBNAME=myhub
In my code, I'm trying to refer to the value of HUBNAME as a string:
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:HUBLISTENACCESS notificationHubPath:HUBNAME];
But Xcode thinks 'myhub' is the name of my variable:
Use of undeclared identifier 'myhub'
Can someone help me figure out how to access 'myhub' as a string?
Upvotes: 1
Views: 84
Reputation: 3649
Something like TO_STR(arg)=#arg HUBNAME=TO_STR("myhub")
? (or just TO_STR(myhub)
w/o quote.)
NSLog(@"%s", HUBNAME); // SO36947532[13085:4401425] myhub
From GNU:
Sometimes you may want to convert a macro argument into a string constant. Parameters are not replaced inside string constants, but you can use the
#
preprocessing operator instead. When a macro parameter is used with a leading#
, the preprocessor replaces it with the literal text of the actual argument, converted to a string constant. Unlike normal parameter replacement, the argument is not macro-expanded first. This is called stringification.
Upvotes: 1