boost.preprocessor BOOST_PP_SEQ_FOR_EACH shows strange error messages

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

2011/8/7 aliko
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
#include #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 :/

Hello,
On Sun, Aug 7, 2011 at 12:05 PM, TONGARI
2011/8/7 aliko
<snip>
#define WITH_NUMBERS(Z0, Z1, SEQ) BOOST_PP_SEQ_ELEM(1, SEQ),
BOOST_PP_SEQ_ELEM(2, SEQ),
I don't think you want to end this line with a comma. Cheers, Will

On 07.08.2011 21:05, TONGARI wrote:
BOOST_PP_SEQ_FOR_EACH cannot be used recursively, I have no solution :/
And BOOST_PP_LIST_FOR_EACH also can't be used the same way? Maybe someone could suggest another strategy to achieve my goals? Based on the definition described in first message firstly I'd like to construct array int bounds[] = {1000,4000, 0, 20000, 4000, 20000, 0, 10000, 4000, 20000, 0, 3000, 1000, 4000, 0, 20000, 4000.....} If I accomplish this task someway maybe I'll understood how to construct other structures.
participants (3)
-
aliko
-
TONGARI
-
Will Mason