B
Bo Peng
Dear list,
I am having trouble with a seemingly very simple problem, namely, I need
to pass a string to C++ code through macro definition:
gcc -DVERSION=0.6.7 test.cpp
while in test.cpp
string version()
{
return VERSION;
}
The above of course does not work. I have tried:
1. gcc -DVERSION="0.6.7" test.cpp
or gcc -DVERSION=\"0.6.7\" test.cpp
works under gcc/linux but not windows/mingw32 gcc. The " somehow get
lost.
2. gcc -DVERSION=0.6.7 test.cpp
but in tet.cpp use a token-paste operator ## to convert 0.6.9 to "0.6.9"
string version()
{
#define VER " ## VERSION ## "
return VER
}
This works fine under linux, windows, but failed on a cluster maehine
(ia64) with gcc 3.2.3. It treat VER as ## VERSION ## .
So, maybe I am missing something really obvious here, what is a portable
way to do this?
Many thanks in advance.
Bo
I am having trouble with a seemingly very simple problem, namely, I need
to pass a string to C++ code through macro definition:
gcc -DVERSION=0.6.7 test.cpp
while in test.cpp
string version()
{
return VERSION;
}
The above of course does not work. I have tried:
1. gcc -DVERSION="0.6.7" test.cpp
or gcc -DVERSION=\"0.6.7\" test.cpp
works under gcc/linux but not windows/mingw32 gcc. The " somehow get
lost.
2. gcc -DVERSION=0.6.7 test.cpp
but in tet.cpp use a token-paste operator ## to convert 0.6.9 to "0.6.9"
string version()
{
#define VER " ## VERSION ## "
return VER
}
This works fine under linux, windows, but failed on a cluster maehine
(ia64) with gcc 3.2.3. It treat VER as ## VERSION ## .
So, maybe I am missing something really obvious here, what is a portable
way to do this?
Many thanks in advance.
Bo