No, the compiler will put the argument between quotes, resulting in this:
"hello"
However, beware that macro substitution doesn't take place near #
and ##
, so if you really need to stringify the argument (even if it's another macro) it's better to write two macros, the first one to expand the argument and the other one to add quotes:
#define STRINGIFY(x) STRINGIFY_AUX(x)
#define STRINGIFY_AUX(x) #x
Or more generally, if you're compiler supports variadic macros (introduced in C99):
#define STRINGIFY(...) STRINGIFY_AUX(__VA_ARGS__)
#define STRINGIFY_AUX(...) #__VA_ARGS__
If you really need a function-like macro that paste a #
at the beginning of the argument, I think you need it to generate a string (otherwise you'd make an invalid token for the compiler), so you could simple generate two string literals that the compiler will "paste":
#include <stdio.h>
#define STRINGIFY(...) STRINGIFY_AUX(__VA_ARGS__)
#define STRINGIFY_AUX(...) #__VA_ARGS__
int main(void)
{
puts(STRINGIFY(#) STRINGIFY(hello));
}
The main
body will look like this in the preprocessor output:
puts("#" "hello");
I hope this is not an obscure corner of the preprocessor that results in undefined behavior, but it shouldn't be a problem since we're not generating another preprocessor instruction.