开发者

Boost preprocessor: Sample not working

I tried to compile a sample from the Boost.Preprocessor library which is:

#include <boost/preprocessor/seq/insert.hpp>
#define SEQ (a)(b)(d)
BOOST_PP_SEQ_INSERT(SEQ, 2, c) // exp开发者_StackOverflow中文版ands to (a)(b)(c)(d)

on Visual Studio 2008 and I get the error error C2065: 'b' : undeclared identifier

Is there a problem with the sample or am I missing something??

Please note: The sequence definition itself is ok. To show this, I compiled this code:

#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;
}

DISCLAIMER: this code is WTF code, and I never intended to use BOOST PP like this :-)


Well, you are trying to compile a source file containing:

(a)(b)(c)(d)

I suppose you should either put this in a context where this code makes sense, or just run the preprocessor (without compiling the result).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜