Accessing the value of a Preprocessor Macro definition Accessing the value of a Preprocessor Macro definition xcode xcode

Accessing the value of a Preprocessor Macro definition


What you are doing is the way to stringize (or stringify) macro values. The indirection is unavoidable.

This is mentioned in the GCC preprocessor manual section (archived link) that Rob linked to:

 #define xstr(s) str(s) #define str(s) #s #define foo 4 str (foo)      ==> "foo" xstr (foo)      ==> xstr (4)      ==> str (4)      ==> "4


NSLog(@"%s", #FOO);

See Stringification. It's the technique you're already using. What was wrong with it?