views:

41

answers:

1

Hi all,

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) // expands 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??

Thanks,

Philipp

EDIT

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 :-)

+1  A: 

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).

visitor
I don't think this is true, see my Edit
Philipp
@Philip: If you take the three line file (boost's sample) and *compile* it, the preprocessor will turn it into `(a)(b)(c)(d)` and then the compiler comes along and makes no sense out of it. That code is not supposed to do anything on its own.
UncleBens
ahh, I see. My fault, thanks for the clarification.
Philipp