Opened 5 years ago
Last modified 5 years ago
#12995 new Bugs
Clang/C2 support
| Reported by: | Owned by: | No-Maintainer | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | preprocessor |
| Version: | Boost 1.64.0 | Severity: | Problem |
| Keywords: | clang c2 visual studio | Cc: |
Description
It would be nice to get Boost to compile under Clang/C2 in Visual C++ 2017. Boost 1.63 almost did that, but Boost 1.64 does not. The problem is that Boost recognizes the compiler as Visual Studio, and then applies the corresponding workarounds. In particular, the workarounds include incorrect "pasting" in the implementation of macros in VC++, but that workaround is then an error under Clang.
Note:
See TracTickets
for help on using tickets.

From what I can see, this is primarily a bug in Boost.PP. Example code that only #includes <boost/mpl/vector.hpp> and nothing more, under Clang 3.9.1 on Windows:
> clang-cl -I r:/ade/boost_1_64_0 test.cc In file included from test.cc:1: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost/boost_1_64_0\boost/mpl/void.hpp(71,1): error: pasting formed 'BOOST_PP_TUPLE_ELEM_O_3(', an invalid preprocessing token [-Winvalid-token-paste] BOOST_MPL_AUX_NA_SPEC(1, is_void_) ^ r:/ade/boost/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(161,40): note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC' #define BOOST_MPL_AUX_NA_SPEC(i, name) \ ^ r:/ade/boost/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(154,47): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_NO_ETI' #define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \ ^ r:/ade/boost/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(65,9): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_MAIN' BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, typename T, na) \ ^ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) r:/ade/boost/boost_1_64_0\boost/mpl/aux_/preprocessor/def_params_tail.hpp(82,11): note: expanded from macro 'BOOST_MPL_PP_DEF_PARAMS_TAIL_IMPL' BOOST_PP_SUB_D(1, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, i) \ ^ r:/ade/boost/boost_1_64_0\boost/preprocessor/arithmetic/sub.hpp(46,37): note: expanded from macro 'BOOST_PP_SUB_D' # define BOOST_PP_SUB_D(d, x, y) BOOST_PP_SUB_D_I(d, x, y) ^ r:/ade/boost/boost_1_64_0\boost/preprocessor/arithmetic/sub.hpp(47,86): note: expanded from macro 'BOOST_PP_SUB_D_I' # define BOOST_PP_SUB_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_SUB_P, BOOST_PP_SU... ^ In file included from test.cc:1: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost/boost_1_64_0\boost/mpl/void.hpp(71,23): error: too many arguments provided to function-like macro invocation BOOST_MPL_AUX_NA_SPEC(1, is_void_) ^ r:/ade/boost/boost_1_64_0\boost/preprocessor/facilities/expand.hpp(26,10): note: macro 'BOOST_PP_EXPAND_I' defined here # define BOOST_PP_EXPAND_I(x) x ^ In file included from test.cc:1: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost/boost_1_64_0\boost/mpl/void.hpp(71,1): error: pasting formed 'BOOST_PP_TUPLE_ELEM_O_3(', an invalid preprocessing token [-Winvalid-token-paste] BOOST_MPL_AUX_NA_SPEC(1, is_void_) [more errors…]You can work around these immediate issues with -Wno-invalid-token-paste (it's a warning that by default is an error). However, it doesn't fix everything:
> clang-cl -Wno-invalid-token-paste -I r:/ade/boost_1_64_0 test.cc In file included from test.cc:1: In file included from r:/ade/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost_1_64_0\boost/mpl/void.hpp(71,23): error: too many arguments provided to function-like macro invocation BOOST_MPL_AUX_NA_SPEC(1, is_void_) ^ r:/ade/boost_1_64_0\boost/preprocessor/facilities/expand.hpp(26,10): note: macro 'BOOST_PP_EXPAND_I' defined here # define BOOST_PP_EXPAND_I(x) x ^ In file included from test.cc:1: In file included from r:/ade/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost_1_64_0\boost/mpl/void.hpp(71,1): error: expected a qualified name after 'typename' BOOST_MPL_AUX_NA_SPEC(1, is_void_) ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(161,40): note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC' #define BOOST_MPL_AUX_NA_SPEC(i, name) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(154,47): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_NO_ETI' #define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(64,11): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_MAIN' BOOST_MPL_PP_PARAMS(i, typename T) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/preprocessor/params.hpp(58,11): note: expanded from macro 'BOOST_MPL_PP_PARAMS' , BOOST_MPL_PP_AUX_PARAM_FUNC \ ^ In file included from test.cc:1: In file included from r:/ade/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost_1_64_0\boost/mpl/void.hpp(71,1): error: expected ',' or '>' in template-parameter-list r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(161,40): note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC' #define BOOST_MPL_AUX_NA_SPEC(i, name) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(154,47): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_NO_ETI' #define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \ ^ #define BOOST_MPL_AUX_NA_SPEC(i, name) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(154,47): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_NO_ETI' #define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(64,11): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_MAIN' BOOST_MPL_PP_PARAMS(i, typename T) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/preprocessor/params.hpp(58,11): note: expanded from macro 'BOOST_MPL_PP_PARAMS' , BOOST_MPL_PP_AUX_PARAM_FUNC \ ^ In file included from test.cc:1: In file included from r:/ade/boost_1_64_0\boost/mpl/vector.hpp:36: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector20.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector10.hpp:18: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/vector0.hpp:17: In file included from r:/ade/boost_1_64_0\boost/mpl/vector/aux_/at.hpp:20: r:/ade/boost_1_64_0\boost/mpl/void.hpp(71,1): error: expected ',' or '>' in template-parameter-list r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(161,40): note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC' #define BOOST_MPL_AUX_NA_SPEC(i, name) \ ^ r:/ade/boost_1_64_0\boost/mpl/aux_/na_spec.hpp(154,47): note: expanded from macro '\ BOOST_MPL_AUX_NA_SPEC_NO_ETI' #define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \ ^