www.digitalmars.com         C & C++   DMDScript  

c++.beta - preprocessing # operator

reply Richard Grant <fractal clark.net> writes:
Applies to current release version.

Following produces "test .hpp". But it should be "test.hpp"

#include <iostream>

#define STRINGIZE(x) DO_STRINGIZE(x)
#define DO_STRINGIZE(x) #x
#define TRANSFORM(x) STRINGIZE(x.hpp)

int main() {
std::cout << TRANSFORM(test) << std::endl;
}

A work around is:

#define

Richard
Mar 27 2003
parent "Walter" <walter digitalmars.com> writes:
I've seen this before, and in my opinion that effect is not supported by the

concatenate tokens.

"Richard Grant" <fractal clark.net> wrote in message
news:b5us29$1ff5$1 digitaldaemon.com...
 Applies to current release version.

 Following produces "test .hpp". But it should be "test.hpp"

 #include <iostream>

 #define STRINGIZE(x) DO_STRINGIZE(x)
 #define DO_STRINGIZE(x) #x
 #define TRANSFORM(x) STRINGIZE(x.hpp)

 int main() {
 std::cout << TRANSFORM(test) << std::endl;
 }

 A work around is:

 #define

 Richard
Mar 27 2003