Created
May 6, 2012 22:30
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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