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 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:
<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
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
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:
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
So there is no need to do this. Regards, Adam
participants (3)
-
Adam Wulkiewicz
-
degski
-
Marcel Raad