[preprocessor] Undeclared identifier BOOST_PP_IIF_0 under Clang only

Hi, I defined a macro using Boost.Preprocessor that compiles and works fine under gcc but fails to compile under Clang. The macro is defined here: https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/... And the error message follows this message, the file using the macro is https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculato... Thanks for any helps, Pierre Talbot Boost.Expected/example/monadic_calculator$ b2 ...patience... ...found 1246 targets... ...updating 2 targets... clang-linux.compile.c++.without-pth bin/clang-linux-3.5.0/debug/monadic_calculator.o monadic_calculator.cpp:141:15: error: use of undeclared identifier 'BOOST_PP_IIF_0' etokens = DO( ^ ../../include/boost/functional/do_yield.hpp:100:17: note: expanded from macro 'DO' #define DO(...) DO_SEQ(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) ^ ../../include/boost/functional/do_yield.hpp:97:3: note: expanded from macro 'DO_SEQ' BOOST_PP_SEQ_FOR_EACH_I(DO_ELEM, seq, seq) \ ^ /usr/local/boost_1_55_0/boost/preprocessor/seq/for_each_i.hpp:27:55: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_I' # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil), 0), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/for.hpp:27:23: note: expanded from macro 'BOOST_PP_FOR' # define BOOST_PP_FOR BOOST_PP_CAT(BOOST_PP_FOR_, BOOST_PP_AUTO_REC(BOOST_PP_FOR_P, 256)) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ <scratch space>:130:1: note: expanded from here BOOST_PP_FOR_1 ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:22:37: note: expanded from macro 'BOOST_PP_FOR_1' # define BOOST_PP_FOR_1(s, p, o, m) BOOST_PP_FOR_1_C(BOOST_PP_BOOL(p(2, s)), s, p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:279:42: note: expanded from macro 'BOOST_PP_FOR_1_C' # define BOOST_PP_FOR_1_C(c, s, p, o, m) BOOST_PP_IIF(c, m, BOOST_PP_TUPLE_EAT_2)(2, s) BOOST_PP_IIF(c, BOOST_PP_FOR_2, BOOST_PP_TUPLE_EAT_4)(BOOST_PP_EXPR_IIF(c, o)(2, s), p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:18:37: note: expanded from macro 'BOOST_PP_IIF' # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:25:39: note: expanded from macro 'BOOST_PP_IIF_I' # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f) ^ <scratch space>:136:1: note: expanded from here BOOST_PP_IIF_0 ^

On 4/2/2014 3:48 PM, Pierre Talbot wrote:
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine under gcc but fails to compile under Clang. The macro is defined here: https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/...
As a quick shot, without actual testing, define BOOST_PP_VARIADICS to 1.
And the error message follows this message, the file using the macro is https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculato...
Thanks for any helps, Pierre Talbot
Boost.Expected/example/monadic_calculator$ b2 ...patience... ...found 1246 targets... ...updating 2 targets... clang-linux.compile.c++.without-pth bin/clang-linux-3.5.0/debug/monadic_calculator.o monadic_calculator.cpp:141:15: error: use of undeclared identifier 'BOOST_PP_IIF_0' etokens = DO( ^ ../../include/boost/functional/do_yield.hpp:100:17: note: expanded from macro 'DO' #define DO(...) DO_SEQ(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) ^ ../../include/boost/functional/do_yield.hpp:97:3: note: expanded from macro 'DO_SEQ' BOOST_PP_SEQ_FOR_EACH_I(DO_ELEM, seq, seq) \ ^ /usr/local/boost_1_55_0/boost/preprocessor/seq/for_each_i.hpp:27:55: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_I' # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil), 0), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/for.hpp:27:23: note: expanded from macro 'BOOST_PP_FOR' # define BOOST_PP_FOR BOOST_PP_CAT(BOOST_PP_FOR_, BOOST_PP_AUTO_REC(BOOST_PP_FOR_P, 256)) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ <scratch space>:130:1: note: expanded from here BOOST_PP_FOR_1 ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:22:37: note: expanded from macro 'BOOST_PP_FOR_1' # define BOOST_PP_FOR_1(s, p, o, m) BOOST_PP_FOR_1_C(BOOST_PP_BOOL(p(2, s)), s, p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:279:42: note: expanded from macro 'BOOST_PP_FOR_1_C' # define BOOST_PP_FOR_1_C(c, s, p, o, m) BOOST_PP_IIF(c, m, BOOST_PP_TUPLE_EAT_2)(2, s) BOOST_PP_IIF(c, BOOST_PP_FOR_2, BOOST_PP_TUPLE_EAT_4)(BOOST_PP_EXPR_IIF(c, o)(2, s), p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:18:37: note: expanded from macro 'BOOST_PP_IIF' # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:25:39: note: expanded from macro 'BOOST_PP_IIF_I' # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f) ^ <scratch space>:136:1: note: expanded from here BOOST_PP_IIF_0 ^

On 04/03/2014 05:31 PM, Edward Diener wrote:
On 4/2/2014 3:48 PM, Pierre Talbot wrote:
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine under gcc but fails to compile under Clang. The macro is defined here: https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/...
As a quick shot, without actual testing, define BOOST_PP_VARIADICS to 1. It worked, thanks, but the problem is that it won't work if the user has previously included preprocessor without having defined this macro. Maybe it should be defined by default if the language version is C++11?
And the error message follows this message, the file using the macro is https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculato...
Thanks for any helps, Pierre Talbot
Boost.Expected/example/monadic_calculator$ b2 ...patience... ...found 1246 targets... ...updating 2 targets... clang-linux.compile.c++.without-pth bin/clang-linux-3.5.0/debug/monadic_calculator.o monadic_calculator.cpp:141:15: error: use of undeclared identifier 'BOOST_PP_IIF_0' etokens = DO( ^ ../../include/boost/functional/do_yield.hpp:100:17: note: expanded from macro 'DO' #define DO(...) DO_SEQ(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) ^ ../../include/boost/functional/do_yield.hpp:97:3: note: expanded from macro 'DO_SEQ' BOOST_PP_SEQ_FOR_EACH_I(DO_ELEM, seq, seq) \ ^ /usr/local/boost_1_55_0/boost/preprocessor/seq/for_each_i.hpp:27:55: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_I' # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil), 0), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/for.hpp:27:23: note: expanded from macro 'BOOST_PP_FOR' # define BOOST_PP_FOR BOOST_PP_CAT(BOOST_PP_FOR_, BOOST_PP_AUTO_REC(BOOST_PP_FOR_P, 256)) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ <scratch space>:130:1: note: expanded from here BOOST_PP_FOR_1 ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:22:37:
note: expanded from macro 'BOOST_PP_FOR_1' # define BOOST_PP_FOR_1(s, p, o, m) BOOST_PP_FOR_1_C(BOOST_PP_BOOL(p(2, s)), s, p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:279:42:
note: expanded from macro 'BOOST_PP_FOR_1_C' # define BOOST_PP_FOR_1_C(c, s, p, o, m) BOOST_PP_IIF(c, m, BOOST_PP_TUPLE_EAT_2)(2, s) BOOST_PP_IIF(c, BOOST_PP_FOR_2, BOOST_PP_TUPLE_EAT_4)(BOOST_PP_EXPR_IIF(c, o)(2, s), p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:18:37: note: expanded from macro 'BOOST_PP_IIF' # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:25:39: note: expanded from macro 'BOOST_PP_IIF_I' # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f) ^ <scratch space>:136:1: note: expanded from here BOOST_PP_IIF_0 ^
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On 4/3/2014 3:38 PM, Pierre Talbot wrote:
On 04/03/2014 05:31 PM, Edward Diener wrote:
On 4/2/2014 3:48 PM, Pierre Talbot wrote:
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine under gcc but fails to compile under Clang. The macro is defined here: https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/...
As a quick shot, without actual testing, define BOOST_PP_VARIADICS to 1. It worked, thanks, but the problem is that it won't work if the user has previously included preprocessor without having defined this macro.
Agreed for any given translation unit which includes any of your headers. I would just explain to end-users of your library using Boost 1.55 or lower that they need to define BOOST_PP_VARIADICS to 1 if they are using clang and Boost PP. And/or you could also add to your library ( in maybe a setup.hpp header ) something like: #if defined(BOOST_PP_VARIADICS) #if !BOOST_PP_VARIADICS #error BOOST_PP_VARIADICS cannot be defined as 0 when using Expected #endif #else #define BOOST_PP_VARIADICS 1 #endif
Maybe it should be defined by default if the language version is C++11?
In the latest modular-boost BOOST_PP_VARIADICS is defined as 1 for all versions of clang in the Boost PP config.hpp header. This was a conservative oversight regarding clang by Paul Mensonides when variadic macro support was added to pplib. I have since confirmed with clang developers that clang always supported variadic macros even in their earliest implementations and even without C++11 support.
And the error message follows this message, the file using the macro is https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculato...
Thanks for any helps, Pierre Talbot
Boost.Expected/example/monadic_calculator$ b2 ...patience... ...found 1246 targets... ...updating 2 targets... clang-linux.compile.c++.without-pth bin/clang-linux-3.5.0/debug/monadic_calculator.o monadic_calculator.cpp:141:15: error: use of undeclared identifier 'BOOST_PP_IIF_0' etokens = DO( ^ ../../include/boost/functional/do_yield.hpp:100:17: note: expanded from macro 'DO' #define DO(...) DO_SEQ(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) ^ ../../include/boost/functional/do_yield.hpp:97:3: note: expanded from macro 'DO_SEQ' BOOST_PP_SEQ_FOR_EACH_I(DO_ELEM, seq, seq) \ ^ /usr/local/boost_1_55_0/boost/preprocessor/seq/for_each_i.hpp:27:55: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_I' # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil), 0), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/for.hpp:27:23: note: expanded from macro 'BOOST_PP_FOR' # define BOOST_PP_FOR BOOST_PP_CAT(BOOST_PP_FOR_, BOOST_PP_AUTO_REC(BOOST_PP_FOR_P, 256)) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ <scratch space>:130:1: note: expanded from here BOOST_PP_FOR_1 ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:22:37:
note: expanded from macro 'BOOST_PP_FOR_1' # define BOOST_PP_FOR_1(s, p, o, m) BOOST_PP_FOR_1_C(BOOST_PP_BOOL(p(2, s)), s, p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:279:42:
note: expanded from macro 'BOOST_PP_FOR_1_C' # define BOOST_PP_FOR_1_C(c, s, p, o, m) BOOST_PP_IIF(c, m, BOOST_PP_TUPLE_EAT_2)(2, s) BOOST_PP_IIF(c, BOOST_PP_FOR_2, BOOST_PP_TUPLE_EAT_4)(BOOST_PP_EXPR_IIF(c, o)(2, s), p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:18:37: note: expanded from macro 'BOOST_PP_IIF' # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:25:39: note: expanded from macro 'BOOST_PP_IIF_I' # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f) ^ <scratch space>:136:1: note: expanded from here BOOST_PP_IIF_0 ^

On 04/03/2014 10:39 PM, Edward Diener wrote:
On 4/3/2014 3:38 PM, Pierre Talbot wrote:
On 04/03/2014 05:31 PM, Edward Diener wrote:
On 4/2/2014 3:48 PM, Pierre Talbot wrote:
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine under gcc but fails to compile under Clang. The macro is defined here: https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/...
As a quick shot, without actual testing, define BOOST_PP_VARIADICS to 1. It worked, thanks, but the problem is that it won't work if the user has previously included preprocessor without having defined this macro.
Agreed for any given translation unit which includes any of your headers.
I would just explain to end-users of your library using Boost 1.55 or lower that they need to define BOOST_PP_VARIADICS to 1 if they are using clang and Boost PP. And/or you could also add to your library ( in maybe a setup.hpp header ) something like:
#if defined(BOOST_PP_VARIADICS) #if !BOOST_PP_VARIADICS #error BOOST_PP_VARIADICS cannot be defined as 0 when using Expected #endif #else #define BOOST_PP_VARIADICS 1 #endif Ok, this is a library intented to end in Boost so it won't be a problem if the issue is resolved in the last PP version. I'll use your solution meanwhile.
Maybe it should be defined by default if the language version is C++11?
In the latest modular-boost BOOST_PP_VARIADICS is defined as 1 for all versions of clang in the Boost PP config.hpp header. This was a conservative oversight regarding clang by Paul Mensonides when variadic macro support was added to pplib. I have since confirmed with clang developers that clang always supported variadic macros even in their earliest implementations and even without C++11 support. Thanks for the insight!
Pierre
And the error message follows this message, the file using the macro is https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculato...
Thanks for any helps, Pierre Talbot
Boost.Expected/example/monadic_calculator$ b2 ...patience... ...found 1246 targets... ...updating 2 targets... clang-linux.compile.c++.without-pth bin/clang-linux-3.5.0/debug/monadic_calculator.o monadic_calculator.cpp:141:15: error: use of undeclared identifier 'BOOST_PP_IIF_0' etokens = DO( ^ ../../include/boost/functional/do_yield.hpp:100:17: note: expanded from macro 'DO' #define DO(...) DO_SEQ(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) ^ ../../include/boost/functional/do_yield.hpp:97:3: note: expanded from macro 'DO_SEQ' BOOST_PP_SEQ_FOR_EACH_I(DO_ELEM, seq, seq) \ ^ /usr/local/boost_1_55_0/boost/preprocessor/seq/for_each_i.hpp:27:55: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_I' # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil), 0), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/for.hpp:27:23: note: expanded from macro 'BOOST_PP_FOR' # define BOOST_PP_FOR BOOST_PP_CAT(BOOST_PP_FOR_, BOOST_PP_AUTO_REC(BOOST_PP_FOR_P, 256)) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ /usr/local/boost_1_55_0/boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ <scratch space>:130:1: note: expanded from here BOOST_PP_FOR_1 ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:22:37:
note: expanded from macro 'BOOST_PP_FOR_1' # define BOOST_PP_FOR_1(s, p, o, m) BOOST_PP_FOR_1_C(BOOST_PP_BOOL(p(2, s)), s, p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/repetition/detail/for.hpp:279:42:
note: expanded from macro 'BOOST_PP_FOR_1_C' # define BOOST_PP_FOR_1_C(c, s, p, o, m) BOOST_PP_IIF(c, m, BOOST_PP_TUPLE_EAT_2)(2, s) BOOST_PP_IIF(c, BOOST_PP_FOR_2, BOOST_PP_TUPLE_EAT_4)(BOOST_PP_EXPR_IIF(c, o)(2, s), p, o, m) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:18:37: note: expanded from macro 'BOOST_PP_IIF' # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f) ^ /usr/local/boost_1_55_0/boost/preprocessor/control/iif.hpp:25:39: note: expanded from macro 'BOOST_PP_IIF_I' # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f) ^ <scratch space>:136:1: note: expanded from here BOOST_PP_IIF_0 ^
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Edward Diener
-
Pierre Talbot