Boost logo

Boost Users :

Subject: Re: [Boost-users] boost.preprocessor BOOST_PP_SEQ_FOR_EACH shows strange error messages
From: TONGARI (tongari95_at_[hidden])
Date: 2011-08-07 13:05:35


2011/8/7 aliko <ali.tlisov_at_[hidden]>

> Hi!
> I'm trying to utilize preprocessor library for the first time and my
> questions probably are too stupid for this list but I have not found another
> place to ask.:)
> In series of projects I have a repetitive task with defining many variables
> and structures based on configuration of embedded platform.
> First I've tried to generate array of numbers from ADC, the main definition
> from which all the variables and structures should be created. But I've got
> a strange error messages which I can't interpret right way.
>
> My code is:
> **************************************************************************
> #include <boost/preprocessor/seq.hpp>
> #include <boost/preprocessor/tuple.hpp>
>
> #define POS_NAME 0
> #define POS_PIN 1
> #define POS_SKIP 2
> #define POS_K 3
> #define POS_TYPES 4
> #define POS_SCALES 5
>
> #define NFIELDS 6
>
> #define NSIGS 5
>
> enum {DISCRETE, ANALOG, CONTROL, MEASURE, END_TYPES};
>
> //NAME, PIN, SKIP, FILTERK, DATATYPES, SCALES
> #define ADC ( \
> (POSITION, 0, 0, 100, (ANALOG, CONTROL, MEASURE), \
> (((DISCRETE, ANALOG) (1000, 4000) (0, 20000)) \
> ((ANALOG, CONTROL) (4000, 20000) (0, 10000)) \
> ((ANALOG, MEASURE) (4000, 20000) (0, 3000)))), \
> (CURRENT, 1, 0, 100, (ANALOG, CONTROL), \
> (((DISCRETE, ANALOG) (1000, 4000) (0, 20000)) \
> ((ANALOG, CONTROL) (4000, 20000) (0, 10000)))), \
> (HALL, 2, 0, 100, (ANALOG, CONTROL), \
> (((DISCRETE, ANALOG) (1000, 4000) (0, 20000)) \
> ((ANALOG, CONTROL) (4000, 20000) (0, 10000)))), \
> (PRESSURE, 4, 0, 100, (ANALOG, CONTROL, MEASURE), \
> (((DISCRETE, ANALOG), (1000, 4000) (0, 20000)) \
> ((ANALOG, CONTROL) (4000, 20000) (0, 10000)) \
> ((ANALOG, MEASURE) (4000, 20000) (0, 3000)))), \
> (TEMPERATURE, 10, 0, 100, (CONTROL, MEASURE), \
> (((DISCRETE, CONTROL) (1000, 4000) (0, 20000)) \
> ((CONTROL, MEASURE) (4000, 20000) (0, 3000)))) \
> )
>
> #define WITH_NUMBERS(Z0, Z1, SEQ) BOOST_PP_SEQ_ELEM(1, SEQ),
> BOOST_PP_SEQ_ELEM(2, SEQ),
>
> #define TO_NUMBERS(Z0, Z1, SEQ) BOOST_PP_SEQ_FOR_EACH(WITH_**NUMBERS, _,
> SEQ)
>
> #define TO_SCALES(Z0, Z1, TUPLE) BOOST_PP_SEQ_FOR_EACH(TO_**NUMBERS, _,
> BOOST_PP_TUPLE_ELEM(NFIELDS, POS_SCALES, TUPLE))
>
> unsigned int bounds[] = {BOOST_PP_SEQ_FOR_EACH(TO_**SCALES, _,
> BOOST_PP_TUPLE_TO_SEQ(NSIGS, ADC))};
> **************************************************************************
>
> The errors are:
> ./test_preprocess.cpp:56:1: error: ‘TO_NUMBERS’ was not declared in this
> scope
> ./test_preprocess.cpp:56:1: error: ‘_’ was not declared in this scope
> ./test_preprocess.cpp:56:1: error: ‘(0, (._74)1u)’ cannot be used as a
> function
> ./test_preprocess.cpp:56:1: error: ‘(0, (._74)2u)’ cannot be used as a
> function
> ./test_preprocess.cpp:56:1: error: ‘(0, (._74)3u)’ cannot be used as a
> function
> ./test_preprocess.cpp:56:1: error: ‘BOOST_PP_SEQ_FOR_EACH’ was not declared
> in this scope
> ... end so on
> Why it's not sees TO_NUMBERS definition?
>

BOOST_PP_SEQ_FOR_EACH cannot be used recursively, I have no solution :/



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net