Last active
August 22, 2018 11:12
-
-
Save neverunlucky/7d3b0430daa32cf9bcc54d65c1003435 to your computer and use it in GitHub Desktop.
Objective-C marco define symbol to NSString
This file contains hidden or 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
//Credit: https://stackoverflow.com/questions/1793882/how-to-make-a-macro-that-can-take-a-string | |
#define STRINGIFY2(x) #x | |
#define STRINGIFY(x) STRINGIFY2(x) | |
#define PASTE2(a, b) a##b | |
#define PASTE(a, b) PASTE2(a, b) | |
#define PRINTTHIS(text) \ | |
NSLog(PASTE(@, STRINGIFY(text))); | |
//Result | |
#define PRINTTHIS(abcde) \ | |
NSLog(@"abcde"); | |
//Result | |
#define abcde ongggg | |
NSLog(@STRINGIFY(abcde)); | |
//output: ongggg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment