我试着从
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:-)