March 27, 2003 preprocessing # operator | ||||
---|---|---|---|---|
| ||||
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 |
March 27, 2003 Re: preprocessing # operator | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Grant | 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 > > |
Copyright © 1999-2021 by the D Language Foundation