Search code examples
c++cmacrosstringify

Is there a way to remove quotes in a C macro?


Suppose I want to un-stringify the macro argument which should transform "text" to text.

#define UN_STRINGIFY(x) /* some macro magic here */

Now calling this macro will remove "" from its argument

UN_STRINGIFY("text") // results in ----> text

This would be the opposite of macro stringification:

#define STRINGIFY(x) #x

Is this possible, or am I playing with macro evilness?


Solution

  • It's not possible. And that's probably a good thing: If you pass a string you assume you can put pretty much everything in it. Un-stringifying it would suddenly result in the compiler actually caring about the contents of that string.