Boost.Preprocessorライブラリからサンプルをコンパイルしようとしました。
#include <boost/preprocessor/seq/insert.hpp>
#define SEQ (a)(b)(d)
BOOST_PP_SEQ_INSERT(SEQ, 2, c) // expands to (a)(b)(c)(d)
Visual Studio 2008 でエラーが発生するerror C2065: 'b' : undeclared identifier
サンプルに問題がありますか、それとも何か不足していますか??
注意: シーケンス定義自体は問題ありません。これを示すために、次のコードをコンパイルしました。
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#define SEQ (w)(x)
#define MACRO(r, data, elem) BOOST_PP_CAT(elem, data)
struct w_
{
int x;
};
void test()
{
BOOST_PP_SEQ_FOR_EACH(MACRO, _, SEQ);
x_.x = 3;
}
免責事項: このコードは WTF コードであり、私はこのような BOOST PP を使用するつもりはありません :-)