Thursday, September 15, 2005
Tricks in Resource Compiler or Compatible preprocessor
The question is:
We defined “SOAM_RELEASE_BUILD” in environment as an Integer like
“set SOAM_RELEASE_BUILD=12345”
but in resource script, we need the string value of it like
VALUE "ProductVersion", VersionNumber ß a string here
So we defined the following macro in the resource script like
#define xstr(x) str(x)
#define str(x) #x
If you want to stringify the result of expansion of a macro argument, you have to use two levels of macros.
#define xstr(s) str(s)
#define str(s) #s
#define foo 4
str (foo)
==> "foo"
xstr (foo)
==> xstr (4)
==> str (4)
==> "4"
quoted from
http://www.ugcs.caltech.edu/info/gcc/cpp_3.html