How to make a literal string by merging a non string macro as follow?
#define SOC 12
printf("This is the default SoC:" SOC "!");
[UPDATE]
This is embedded cpp 11 and I'd like to limit resource usage so I need a compile-time solution, not runtime.
CodePudding user response:
With preprocessor, you might stringify the value:
#define STRINGIFY(s) #s
#define STRINGIFY_VALUE(s) STRINGIFY(s)
and then use concatenation of C-strings:
printf("This is the default SoC:" STRINGIFY_VALUE(SOC) "!");