Boost logo

Boost :

Subject: Re: [boost] Fwd: [clang] clang-cl expansion of macros
From: Edward Diener (eldiener_at_[hidden])
Date: 2017-04-29 18:51:33


On 4/29/2017 3:58 AM, degski via Boost wrote:
> On 16 April 2016 at 17:58, Edward Diener <eldiener_at_[hidden]> wrote:
>
>> What I strongly suspect will finally happen is that clang will not fix
>> these emulation problems because they are too tricky and numerous to do.
>> Instead they will probably declare that their emulation is good enough for
>> the majority of preprocessor constructs and that Boost PP, which pushes the
>> preprocessor to its limits, is not meant to work with their flawed VC++
>> emulation. I hope I am wrong about that supposition, but having spent much
>> time in Boost PP and Boost VMD trying to workaround VC++ non-standard
>> preprocessor behavior I can envision that having to code "down" to that
>> behavior in numerous complicated instances will be too much time consuming
>> work for the clang developers who have chosen to work with VC++
>> preprocessor emulation.
>>
>
>
> I've successfully built boost-1.64 with VC1410 (from the developer command
> prompt). Trying to use boost with a project using Clang 4.0.0 (both the
> LLVM and C2 backends) gives me the following PP error messages:

What are you trying to compile/build/run ?

As explained Boost PP does not support clang-cl, which has a buggy
emulation of the non-standard VC++ preprocessor. In Boost, using:

using clang : 4.0 : some_path/clang++
  :
  <cxxflags>-fmacro-backtrace-limit=0
  <cxxflags>-Wno-invalid-token-paste
  <compileflags>-fmsc-version=1900
  <linkflags>-fuse-ld=lld
  ;

you should be able to compile/build Boost libraries. A change was made
to Boost PP to support this by having Boost PP use a C++ standard
preprocessor whenever both _MSC_VER and __clang__ was defined. This
decision was based on the fact that VC++'s clang/c2 uses this mode and
should work using the normal Boost Build clang.jam instead of clang-win.jam.

>
>
> 1>------ Rebuild All started: Project: test, Configuration: Debug x64 ------
> 1> In file included from test.cpp:16:
> 1> In file included from z:\vc\x64\include\boost/filesystem.hpp:16:
> 1> In file included from z:\vc\x64\include\boost/filesystem/path.hpp:28:
> 1> In file included from z:\vc\x64\include\boost/iterat
> or/iterator_facade.hpp:12:
> 1> In file included from z:\vc\x64\include\boost/iterat
> or/interoperable.hpp:11:
> 1> In file included from z:\vc\x64\include\boost/mpl/or.hpp:43:
> 1> In file included from z:\vc\x64\include\boost/mpl/au
> x_/include_preprocessed.hpp:37:
> 1>z:\vc\x64\include\boost/mpl/aux_/preprocessed/plain/or.hpp(59,7): error :
> too many arguments provided to function-like macro invocation
> 1> 2
> 1> ^
> 1> z:\vc\x64\include\boost/preprocessor/facilities/expand.hpp(26,10):
> note: macro 'BOOST_PP_EXPAND_I' defined here
> 1> # define BOOST_PP_EXPAND_I(x) x
> 1> ^
> 1> In file included from test.cpp:16:
> 1> In file included from z:\vc\x64\include\boost/filesystem.hpp:16:
> 1> In file included from z:\vc\x64\include\boost/filesystem/path.hpp:28:
> 1> In file included from z:\vc\x64\include\boost/iterat
> or/iterator_facade.hpp:12:
> 1> In file included from z:\vc\x64\include\boost/iterat
> or/interoperable.hpp:11:
> 1> In file included from z:\vc\x64\include\boost/mpl/or.hpp:43:
> 1> In file included from z:\vc\x64\include\boost/mpl/au
> x_/include_preprocessed.hpp:37:
> 1>z:\vc\x64\include\boost/mpl/aux_/preprocessed/plain/or.hpp(58,1): error :
> expected a qualified name after 'typename'
> 1> BOOST_MPL_AUX_NA_SPEC2(
> 1> ^
> 1> z:\vc\x64\include\boost/mpl/aux_/na_spec.hpp(166,44): note: expanded
> from macro 'BOOST_MPL_AUX_NA_SPEC2'
> 1> #define BOOST_MPL_AUX_NA_SPEC2(i, j, name) \
> 1> ^
> 1> z:\vc\x64\include\boost/mpl/aux_/na_spec.hpp(64,11): note: expanded
> from macro '\
> 1>
> 1> BOOST_MPL_AUX_NA_SPEC_MAIN'
> 1> BOOST_MPL_PP_PARAMS(i, typename T) \
> 1> ^
> 1> z:\vc\x64\include\boost/mpl/aux_/preprocessor/params.hpp(58,11): note:
> expanded from macro 'BOOST_MPL_PP_PARAMS'
> 1> , BOOST_MPL_PP_AUX_PARAM_FUNC \
> 1> ^
> 1> In file included from test.cpp:16:
> 1> In file included from z:\vc\x64\include\boost/filesystem.hpp:16:
> 1> In file included from z:\vc\x64\include\boost/filesystem/path.hpp:28:
> 1> In file included from z:\vc\x64\include\boost/iterat
> or/iterator_facade.hpp:12:
> 1> In file included from z:\vc\x64\include\boost/iterat
> or/interoperable.hpp:11:
> 1> In file included from z:\vc\x64\include\boost/mpl/or.hpp:43:
> 1> In file included from z:\vc\x64\include\boost/mpl/au
> x_/include_preprocessed.hpp:37:
> 1>z:\vc\x64\include\boost/mpl/aux_/preprocessed/plain/or.hpp(58,1): error :
> expected ',' or '>' in template-parameter-list
>
>
> Up till now I was using a hacked boost-1.62. So in order to see what would
> happen, I also built boost-1.63. Apart from a small change in
> type_with_alignment.hpp (adding a ckeck for _MSC_VER not to exist if
> __clang__ does exist in line 87), boost-1.63 compiles without a problem (no
> specific (relevant to the emulation) command line parameters).
>
> Is there a macro I should define or is there something else I should set/do
> in order to use boost-1.64 with Clang 4.0.0 on windows? Any other
> suggestions?
>
> degski
>


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