Skip to content

Instantly share code, notes, and snippets.

@serkodev
Created November 5, 2018 10:54
Show Gist options
  • Select an option

  • Save serkodev/8040e0b320ca3436c839571b3a7dc482 to your computer and use it in GitHub Desktop.

Select an option

Save serkodev/8040e0b320ca3436c839571b3a7dc482 to your computer and use it in GitHub Desktop.
//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