Skip to content

Instantly share code, notes, and snippets.

@mattyohe
Created May 6, 2012 22:30
Show Gist options
  • Save mattyohe/2624831 to your computer and use it in GitHub Desktop.
Save mattyohe/2624831 to your computer and use it in GitHub Desktop.
Stringify the the value of a macro and turn that into an NSString constant
#define DERP 1234
#define MACRO_NAME(str) @ #str
#define STRINGIFY(str) MACRO_NAME(str)
NSLog(@"%@",MACRO_NAME(DERP));
NSLog(@"%@",STRINGIFY(DERP));
// Output:
// DERP
// 1234 // This is the result we want
// ref: http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment