Boost logo

Boost :

Subject: [boost] [preprocessor] seq/size.hpp BOOST_PP_SEQ_SIZE MSVC empty list warning
From: damien benoist (damien_benoist_at_[hidden])
Date: 2011-04-19 11:29:10


Hello, It seems that BOOST_PP_SEQ_SIZE generates a warning with empty sequences under MSVC (vs 2010/boost 1.46.1). The same call works with gcc. The tests are available below. I've also put a patch but: - I'm really not sure of it (I have never been as far with preproceesor as in boost/preprocesor/) - I only tested it with BOOST_PP_CONFIG_MSVC (it should also be tested with BOOST_PP_CONFIG_EDG) And anyway this warning will likely appear with all macros manipulating sequences. Should this warning just be ignored or disabled with MSVC? More general question: I'm discovering boost. I'm really impressed by the macros in boost/preprocessor. It makes a lot of things possible. But it provides features the preprocessor was not meant for. For that, it uses a lot of tricks. How portable is it? How many architectures is it known to work/not work with? Can we be confident that it should work with any preprocessor? Thanks for your help. $ cat lstsz2.h #include "boost/preprocessor/seq/size.hpp" #define lst0 #define lst1 (a) #define lst2 (a)(b) #define lst3 (a)(b)(c) BOOST_PP_SEQ_SIZE(lst0) BOOST_PP_SEQ_SIZE(lst1) BOOST_PP_SEQ_SIZE(lst2) BOOST_PP_SEQ_SIZE(lst3) $ cpp -I ~/wh/softs/boost/1.46.1 < lstsz2.h ... 0 1 2 3 $ cl -I `cygpath -d "$HOME/wh/softs/boost/1.46.1"` /E lstsz2.h ... 0 1 2 3 lstsz2.h(8) : warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_SIZE_I' $ diff -u 1.46.1/boost/preprocessor/seq/size.hpp.old 1.46.1/boost/preprocessor/seq/size.hpp --- 1.46.1/boost/preprocessor/seq/size.hpp.old 2005-06-21 09:55:15.000000000 +0200 +++ 1.46.1/boost/preprocessor/seq/size.hpp 2011-04-19 14:42:02.218750000 +0200 @@ -13,6 +13,7 @@ # define BOOST_PREPROCESSOR_SEQ_SIZE_HPP # # include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/empty.hpp> # include <boost/preprocessor/config/config.hpp> # include <boost/preprocessor/tuple/eat.hpp> # @@ -21,7 +22,7 @@ # define BOOST_PP_SEQ_SIZE_I(par) BOOST_PP_SEQ_SIZE_II ## par # define BOOST_PP_SEQ_SIZE_II(seq) BOOST_PP_CAT(BOOST_PP_SEQ_SIZE_, BOOST_PP_SEQ_SIZE_0 ## seq) # elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() || BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() -# define BOOST_PP_SEQ_SIZE(seq) BOOST_PP_SEQ_SIZE_I(seq) +# define BOOST_PP_SEQ_SIZE(seq) BOOST_PP_SEQ_SIZE_I(seq BOOST_PP_EMPTY()) # define BOOST_PP_SEQ_SIZE_I(seq) BOOST_PP_CAT(BOOST_PP_SEQ_SIZE_, BOOST_PP_SEQ_SIZE_0 seq) # elif defined(__IBMC__) || defined(__IBMCPP__) # define BOOST_PP_SEQ_SIZE(seq) BOOST_PP_CAT(BOOST_PP_SEQ_SIZE_, BOOST_PP_CAT(BOOST_PP_SEQ_SIZE_0, seq))


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk