c++.beta - preprocessing # operator
- Richard Grant <fractal clark.net> Mar 27 2003
- "Walter" <walter digitalmars.com> Mar 27 2003
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 TRANSFORM(x) STRINGIZE(x##.hpp)
Richard
Mar 27 2003
I've seen this before, and in my opinion that effect is not supported by the Standard. The ## token concatenation operator should be used when trying to 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 TRANSFORM(x) STRINGIZE(x##.hpp) Richard
Mar 27 2003








"Walter" <walter digitalmars.com>