
Sergey wrote:
JF> #define FOO_MACRO(S) BOOST_PP_CAT(BAR_MACRO_, JF> BOOST_PP_SEQ_HEAD(S))(S)
JF> That looks more straightforward to me. Thanks a lot! It's much better! :)
One thing I do know about the preprocessor library is that recursion is not allowed. You can tell that Boost.Preprocessor is using BOOST_PP_CAT internally because it shows up in the preprocessed results (this happened to me before). That behavior is documented at http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/index.html I did a little search and I think your culprit is in boost\preprocessor\seq\enum.hpp:28: # define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)) seq Since PP_CAT in the first version expanded to BAR_MACRO_1(S), the preprocessor expanded it which invokes PP_CAT again. By putting the sequence outside of the PP_CAT macro, it just expanded to BAR_MACRO_1 -- no parenthesis -- and therefor it was not expanded inside PP_CAT macro, and we were safe. Since your own macro was not PP_CAT, there was no recursion in yours and apparently everything worked. At least I think that is what happened :) -- John