Boost logo

Boost Users :

Subject: [Boost-users] [Preprocessor] MSVC, File Iteration, and FLAGS()
From: Robert Rumpf (robert.rumpf_at_[hidden])
Date: 2011-04-14 18:19:33


I’ve reduced my problem to the following code snippet which compiles fine on
GCC, but which fails to compile on MSVC (versions 9 and 10). The error
provided by MSVC is “fatal error C1012: unmatched parenthesis : missing ')'”.
It seems to have to do with the BOOST_PP_ITERATION_FLAGS() directive. I’m
using Boost 1.45.0.

Any thoughts on workarounds or bug-fixes?

Thanks,

Rob Rumpf

*#if* !BOOST_PP_IS_ITERATING

*# ifndef* __FILE_HPP__

*# define* __FILE_HPP__

*# include* <boost/preprocessor/iteration/iterate.hpp>

*# include* <boost/preprocessor/seq/size.hpp>

*# include* <boost/preprocessor/arithmetic/dec.hpp>

/// Set up the first (most outer) nested FOR loop.

*# define* INDICES_1 (A)(B)

/// Set up the second (middle) nested FOR loop.

*# define* INDICES_2 (C)(D)

/// Set up the third (inner) nested FOR loop (1 of 3).

*# define* INDICES_3a (E)(F)

/// Set up the third (inner) nested FOR loop (2 of 3).

*# define* INDICES_3b (G)(H)

/// Set up the third (inner) nested FOR loop (3 of 3).

*# define* INDICES_3c (I)(J)

// Set up the number of iterations (see the Boost.Preprocessor library).

// Set up the filename to be called (which is this one, see the
Boost.Preprocessor library).

*# define* BOOST_PP_ITERATION_PARAMS_1 (3, (0,
BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(INDICES_1)), "file.hpp"))

// Iterate (see the Boost.Preprocessor library) on the first (most outer)
nested FOR loop.

*# include* BOOST_PP_ITERATE()

*# endif* // __FILE_HPP__

// Choose the first iteration.

*#elif* BOOST_PP_ITERATION_DEPTH() == 1

// Set up the number of iterations (see the Boost.Preprocessor library).

// Set up the filename to be called (which is this one, see the
Boost.Preprocessor library).

*# define* BOOST_PP_ITERATION_PARAMS_2 (3, (0,
BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(INDICES_2)), "file.hpp"))

// Iterate (see the Boost.Preprocessor library) on the second (middle)
nested FOR loop.

*# include* BOOST_PP_ITERATE()

// Choose the second iteration.

*#elif* BOOST_PP_ITERATION_DEPTH() == 2

// Set up the number of iterations (see the Boost.Preprocessor library).

// Set up the filename to be called (which is this one, see the
Boost.Preprocessor library).

*# define* BOOST_PP_ITERATION_PARAMS_3 (4, (0,
BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(INDICES_3a)), "file.hpp", 0))

// Iterate (see the Boost.Preprocessor library) on the third (inner) nested
FOR loop (1 of 3).

*# include* BOOST_PP_ITERATE()

// Set up the number of iterations (see the Boost.Preprocessor library).

// Set up the filename to be called (which is this one, see the
Boost.Preprocessor library).

*# define* BOOST_PP_ITERATION_PARAMS_3 (4, (0,
BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(INDICES_3b)), "file.hpp", 1))

// Iterate (see the Boost.Preprocessor library) on the third (inner) nested
FOR loop (2 of 3).

*# include* BOOST_PP_ITERATE()

// Set up the number of iterations (see the Boost.Preprocessor library).

// Set up the filename to be called (which is this one, see the
Boost.Preprocessor library).

*# define* BOOST_PP_ITERATION_PARAMS_3 (4, (0,
BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(INDICES_3c)), "file.hpp", 2))

// Iterate (see the Boost.Preprocessor library) on the third (inner) nested
FOR loop (3 of 3).

*# include* BOOST_PP_ITERATE()

// Look for the third nested loop, but index over INDICES_3a this time.

*#elif* BOOST_PP_ITERATION_DEPTH() == 3 && BOOST_PP_ITERATION_FLAGS() == 0

// Look for the third nested loop, but index over INDICES_3b this time.

*#elif* BOOST_PP_ITERATION_DEPTH() == 3 && BOOST_PP_ITERATION_FLAGS() == 1

// Look for the third nested loop, but index over INDICES_3c this time.

*#elif* BOOST_PP_ITERATION_DEPTH() == 3 && BOOST_PP_ITERATION_FLAGS() == 2

*#endif* // BOOST_PP_IS_ITERATING



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