Using Boost.Geometry with Clang/LLVM & VC14
GGL does not compile with the combo of Clang/LLVM (http://llvm.org/builds/)
and VC14 out of the box. There seem to be comflicts in the resolution of
old MSVC bugs and Clang. On windows __clang__ is defined at the same time
as _MSVC_VER.
Undefining the macro _MSVC_VER before #include
Hi, Degski wrote:
GGL does not compile with the combo of Clang/LLVM (http://llvm.org/builds/) and VC14 out of the box. There seem to be comflicts in the resolution of old MSVC bugs and Clang. On windows __clang__ is defined at the same time as _MSVC_VER.
<snip>
I've run into similar problems before (cannot remember where) with other boost libraries (which I hacked in other ways).
Clang/LLVM with MSVC (and the IDE) works extremely well for a while now. The advantages of Clang/LLVM are well known, no need to spell them out It produces far faster code (almost twice as fast on simple matrix multiplication f.e.. It also gives the best of two worlds as it supports Clang and GCC extensions on Windows (calculated goto), while maintaining (although with a suppressable warning) M$ extensions as well, f.e. in-class template specialization.
Clang/LLVM (3.9.0 as it stands) is much faster than Clang/CL2 (CodeGen) (3.7.0).
I would herewith like to request the development team to integrate Clang/LLVM on Windows as another supported platform.
I'm curious, what problems exactly did you face and when? Is that correct that in this setup (MSVS + Clang) BOOST_CLANG is defined and BOOST_MSVC is NOT defined? Regards, Adam
Hi Adam,
I'm curious, what problems exactly did you face and when?
The problems arose while compiling the minimal example from the get started tutorial. Below I pasted some compiler (Clang-Cl.exe) output. It has all to do with MSVC compiler bugs workarounds. Is that correct that in this setup (MSVS + Clang) BOOST_CLANG is defined
and BOOST_MSVC is NOT defined?
I've added these directives to the code: #if !defined(__clang__) #error __clang__ not defined. #endif #if !defined(_MSVC_VER) #error _MSVC_VER not defined. #endif #if !defined(BOOST_CLANG) #error BOOST_CLANG not defined. #endif #if !defined(BOOST_MSVC) #error BOOST_MSVC not defined. #endif The compiler output is as follows: 1>------ Rebuild All started: Project: test, Configuration: Debug x64 ------ 1> In file included from test.cpp:14: 1> In file included from z:\vc\x64\include\boost/geometry.hpp:22: 1> In file included from z:\vc\x64\include\boost/geometry/geometry.hpp:50: 1> In file included from z:\vc\x64\include\boost/geometry/strategies/strategies.hpp:85: 1> In file included from z:\vc\x64\include\boost/geometry/strategies/transform/matrix_transformers.hpp:40: 1> In file included from z:\vc\x64\include\boost/numeric/ublas/vector.hpp:21: 1> In file included from z:\vc\x64\include\boost/numeric/ublas/storage.hpp:26: 1> In file included from z:\vc\x64\include\boost/numeric/ublas/traits.hpp:29: 1> In file included from z:\vc\x64\include\boost/typeof/typeof.hpp:124: 1>z:\vc\x64\include\boost/typeof/msvc/typeof_impl.hpp(150,31): error : template specialization or definition requires a template parameter list corresponding to the nested type 'base_type' (aka 'msvc_extract_type<ID>') 1> struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature 1> ~~~~~~~~~ ^ 1>z:\vc\x64\include\boost/typeof/msvc/typeof_impl.hpp(150,20): error : nested name specifier for a declaration cannot depend on a template parameter 1> struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature 1> ^~~~~~~~~~~ 1>test.cpp(733,2): error : _MSVC_VER not defined. 1> #error _MSVC_VER not defined. 1> ^ 1>test.cpp(741,2): error : BOOST_MSVC not defined. 1> #error BOOST_MSVC not defined. 1> ^ 1> 4 errors generated. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== So somehow things get mingled it seems. Looking forward to your analysis. Have a good day, degski
Hi, Degski wrote:
The problems arose while compiling the minimal example from the get started tutorial. Below I pasted some compiler (Clang-Cl.exe) output. It has all to do with MSVC compiler bugs workarounds.
<snip> The name of a macro is _MSC_VER, not __MSVC_VER. With MSC+Clang _MSC_VER, __clang__ and BOOST_CLANG are defined after inclusion of Boost.Config. When I compile the Boost.Geometry Quick Start example with MSC+Clang I only get errors in other libraries, i.e. TypeOf and TypeTraits (master branch). I'm still going to replace _MSC_VER checks in Geometry with BOOST_MSVC checks but this will not fix the issues you have. Side note: If you'd like to have this platform fully supported the best way would be to run the regression tests so the maintainers of all liberaries would be able to see the errors. Or you could try to convince people already running the tests on Windows to add one more compiler. Boost.TypeOf
1>z:\vc\x64\include\boost/typeof/msvc/typeof_impl.hpp(150,31): error : template specialization or definition requires a template parameter list corresponding to the nested type 'base_type' (aka 'msvc_extract_type<ID>') 1> struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature 1> ~~~~~~~~~ ^ 1>z:\vc\x64\include\boost/typeof/msvc/typeof_impl.hpp(150,20): error : nested name specifier for a declaration cannot depend on a template parameter 1> struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature 1> ^~~~~~~~~~~
https://github.com/boostorg/typeof/blob/boost-1.60.0/include/boost/typeof/ms...
This code is enabled when BOOST_MSVC is NOT defined or version is lesser
than 1300.
And the file is included if _MSC_VER is defined:
https://github.com/boostorg/typeof/blob/boost-1.60.0/include/boost/typeof/ty...
If BOOST_MSVC is checked instead then the code compiles but then
BOOST_TYPEOF_EMULATION is defined and I'm guessing this is not correct.
With Clang probably native __typeof__ should be used. So either
BOOST_CLANG/__clang__ should be checked here as a special case with
_MSC_VER or it should be checked above as a standalone case, or together
with __GNUC__. What would be prefered?
Boost.TypeTraits
1>D:\lib\modular-boost\boost/type_traits/has_nothrow_assign.hpp(64,7):
error : no template named 'is_assignable'; did you mean
'std::is_assignable'?
1> BOOST_HAS_NOTHROW_ASSIGN(T)
1> ^
1> D:\lib\modular-boost\boost/type_traits/intrinsics.hpp(199,96) :
note: expanded from macro 'BOOST_HAS_NOTHROW_ASSIGN'
1> # define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) &&
!is_volatile<T>::value && is_assignable
Adam Wulkiewicz wrote
Boost.TypeTraits
1>D:\lib\modular-boost\boost/type_traits/has_nothrow_assign.hpp(64,7): error : no template named 'is_assignable'; did you mean 'std::is_assignable'? 1> BOOST_HAS_NOTHROW_ASSIGN(T) 1> ^ 1> D:\lib\modular-boost\boost/type_traits/intrinsics.hpp(199,96) : note: expanded from macro 'BOOST_HAS_NOTHROW_ASSIGN' 1> # define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile <T> ::value && is_assignable<T&, const T&>::value) 1> ^ 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(577,9) : note: 'std::is_assignable' declared here 1> struct is_assignable 1> ^
1>D:\lib\modular-boost\boost/type_traits/has_nothrow_constructor.hpp(26,84): error : no template named 'is_default_constructible'; did you mean 'std::is_default_constructible'? 1> template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{}; 1> ^ 1> D:\lib\modular-boost\boost/type_traits/intrinsics.hpp(193,80) : note: expanded from macro 'BOOST_HAS_NOTHROW_CONSTRUCTOR' 1> # define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) && is_default_constructible <T> ::value) 1> ^ 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(539,9) : note: 'std::is_default_constructible' declared here 1> struct is_default_constructible 1> ^
I'm guessing that more type traits suffer from this.
That should be fixed with https://github.com/boostorg/type_traits/pull/24. -- View this message in context: http://boost.2283326.n4.nabble.com/Using-Boost-Geometry-with-Clang-LLVM-VC14... Sent from the Boost - Users mailing list archive at Nabble.com.
Adam Wulkiewicz wrote:
I only get errors in other libraries, i.e. TypeOf and TypeTraits (master branch). I'm still going to replace _MSC_VER checks in Geometry with BOOST_MSVC checks but this will not fix the issues you have.
In Geometry only some pragmas disabling warnings are enabled this way. So everything is ok.
Boost.TypeOf
https://github.com/boostorg/typeof/pull/3
Boost.TypeTraits
https://github.com/boostorg/type_traits/pull/24
P.S. In both cases you could create a pull request with proposed change on GitHub or create a ticket: https://svn.boost.org/trac/boost/newticket if maintainers of those libraries didn't answer here.
So there is no need to do this. Regards, Adam
participants (3)
-
Adam Wulkiewicz
-
degski
-
Marcel Raad