Discussion:
[preprocessor] Undeclared identifier BOOST_PP_IIF_0 under Clang only
Pierre Talbot
2014-04-02 19:48:04 UTC
Permalink
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/do_yield.hpp

And the error message follows this message, the file using the macro is
https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculator/monadic_calculator.cpp

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
^
Edward Diener
2014-04-03 15:31:22 UTC
Permalink
Post by Pierre Talbot
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine
https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/do_yield.hpp
As a quick shot, without actual testing, define BOOST_PP_VARIADICS to 1.
Post by Pierre Talbot
And the error message follows this message, the file using the macro is
https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculator/monadic_calculator.cpp
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) \
^
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)
^
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
^
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)
^
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)
^
expanded from macro 'BOOST_PP_IIF'
# define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
^
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
^
Pierre Talbot
2014-04-03 19:38:12 UTC
Permalink
Post by Edward Diener
Post by Pierre Talbot
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine
https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/do_yield.hpp
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?
Post by Edward Diener
Post by Pierre Talbot
And the error message follows this message, the file using the macro is
https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculator/monadic_calculator.cpp
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) \
^
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)
^
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
^
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)
^
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)
^
expanded from macro 'BOOST_PP_IIF'
# define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
^
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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Edward Diener
2014-04-03 20:39:01 UTC
Permalink
Post by Pierre Talbot
Post by Edward Diener
Post by Pierre Talbot
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine
https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/do_yield.hpp
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
Post by Pierre Talbot
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.
Post by Pierre Talbot
Post by Edward Diener
Post by Pierre Talbot
And the error message follows this message, the file using the macro is
https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculator/monadic_calculator.cpp
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) \
^
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)
^
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
^
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)
^
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)
^
expanded from macro 'BOOST_PP_IIF'
# define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
^
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
^
Pierre Talbot
2014-04-03 21:16:17 UTC
Permalink
Post by Edward Diener
Post by Pierre Talbot
Post by Edward Diener
Post by Pierre Talbot
Hi,
I defined a macro using Boost.Preprocessor that compiles and works fine
https://github.com/ptal/Boost.Expected/blob/master/include/boost/functional/do_yield.hpp
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 (
#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.
Post by Edward Diener
Post by Pierre Talbot
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
Post by Edward Diener
Post by Pierre Talbot
Post by Edward Diener
Post by Pierre Talbot
And the error message follows this message, the file using the macro is
https://github.com/ptal/Boost.Expected/blob/master/example/monadic_calculator/monadic_calculator.cpp
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) \
^
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)
^
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
^
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)
^
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)
^
expanded from macro 'BOOST_PP_IIF'
# define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
^
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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...