[preprocessor] CAT and '-' token

Hi, I guess this is more of a regular preprocessor question than a Boost.Preprocessor specific one, but: Shouldn't it be possible to concat tokens starting with (or solely consisting of) a '-'? The example at the end of this posting yields the errors: error: pasting "-" and "debug" does not give a valid preprocessing token error: pasting "foo" and "-" does not give a valid preprocessing token --- #include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/stringize.hpp> #include <iostream> #define MODULE foo #define VARIANT debug #define NAME BOOST_PP_CAT(MODULE, BOOST_PP_CAT(-, VARIANT)) void foo() { std::cout << "The name is: " << BOOST_PP_STRINGIZE(NAME) << '\n'; } --- Any workaround? I'm using Boost from cvs at RC_1_34_0 and g++ 4.0.2 under OpenSuse 10. / Johan

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Johan Nilsson
I guess this is more of a regular preprocessor question than a Boost.Preprocessor specific one, but:
Shouldn't it be possible to concat tokens starting with (or solely consisting of) a '-'? The example at the end of this posting yields the errors:
error: pasting "-" and "debug" does not give a valid preprocessing token error: pasting "foo" and "-" does not give a valid preprocessing token
Token-pasting must result in a single preprocessing token. So, there are a very limited few things that you can paste with '-'. In particular, '-VARIANT' is two pp-tokens, so the diagnostic is correct. For what you want to do below, token-pasting isn't necessary. Just having... #define NAME MODULE-VARIANT BOOST_PP_STRINGIZE(NAME) // or: BOOST_PP_STRINGIZE(MODULE-VARIANT) ...should be sufficient. Regards, Paul Mensonides

Paul Mensonides wrote: [snip]
Token-pasting must result in a single preprocessing token. So, there are a very limited few things that you can paste with '-'. In particular, '-VARIANT' is two pp-tokens, so the diagnostic is correct. For what you want to do below, token-pasting isn't necessary. Just having...
#define NAME MODULE-VARIANT
BOOST_PP_STRINGIZE(NAME) // or: BOOST_PP_STRINGIZE(MODULE-VARIANT)
...should be sufficient.
As simple as that ... ;-) Thanks! // Johan
participants (2)
-
Johan Nilsson
-
Paul Mensonides