From f6fdfb92913f5c871bc9fe22629d7a79a8f0cc7c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 4 Jul 2021 18:49:01 +0300 Subject: [PATCH 1/6] Define BOOST_CLANG_VERSION --- include/boost/config/compiler/clang.hpp | 2 + .../boost/config/compiler/clang_version.hpp | 77 +++++++++++++++++++ include/boost/config/compiler/xlcpp.hpp | 1 + 3 files changed, 80 insertions(+) create mode 100644 include/boost/config/compiler/clang_version.hpp diff --git a/include/boost/config/compiler/clang.hpp b/include/boost/config/compiler/clang.hpp index 9d8ba7d7..f28da107 100644 --- a/include/boost/config/compiler/clang.hpp +++ b/include/boost/config/compiler/clang.hpp @@ -351,3 +351,5 @@ // Macro used to identify the Clang compiler. #define BOOST_CLANG 1 +// BOOST_CLANG_VERSION +#include diff --git a/include/boost/config/compiler/clang_version.hpp b/include/boost/config/compiler/clang_version.hpp new file mode 100644 index 00000000..c0741e18 --- /dev/null +++ b/include/boost/config/compiler/clang_version.hpp @@ -0,0 +1,77 @@ +// Copyright 2021 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#if !defined(__APPLE) + +# define BOOST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + +#else +# define BOOST_CLANG_REPORTED_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + +// https://en.wikipedia.org/wiki/Xcode#Toolchain_versions + +# if BOOST_CLANG_REPORTED_VERSION >= 130000 +# define BOOST_CLANG_VERSION 120000 + +# elif BOOST_CLANG_REPORTED_VERSION >= 120005 +# define BOOST_CLANG_VERSION 110100 + +# elif BOOST_CLANG_REPORTED_VERSION >= 120000 +# define BOOST_CLANG_VERSION 100000 + +# elif BOOST_CLANG_REPORTED_VERSION >= 110003 +# define BOOST_CLANG_VERSION 90000 + +# elif BOOST_CLANG_REPORTED_VERSION >= 110000 +# define BOOST_CLANG_VERSION 80000 + +# elif BOOST_CLANG_REPORTED_VERSION >= 100001 +# define BOOST_CLANG_VERSION 70000 + +# elif BOOST_CLANG_REPORTED_VERSION >= 100000 +# define BOOST_CLANG_VERSION 60001 + +# elif BOOST_CLANG_REPORTED_VERSION >= 90100 +# define BOOST_CLANG_VERSION 50002 + +# elif BOOST_CLANG_REPORTED_VERSION >= 90000 +# define BOOST_CLANG_VERSION 40000 + +# elif BOOST_CLANG_REPORTED_VERSION >= 80000 +# define BOOST_CLANG_VERSION 30900 + +# elif BOOST_CLANG_REPORTED_VERSION >= 70300 +# define BOOST_CLANG_VERSION 30800 + +# elif BOOST_CLANG_REPORTED_VERSION >= 70000 +# define BOOST_CLANG_VERSION 30700 + +# elif BOOST_CLANG_REPORTED_VERSION >= 60100 +# define BOOST_CLANG_VERSION 30600 + +# elif BOOST_CLANG_REPORTED_VERSION >= 60000 +# define BOOST_CLANG_VERSION 30500 + +# elif BOOST_CLANG_REPORTED_VERSION >= 50100 +# define BOOST_CLANG_VERSION 30400 + +# elif BOOST_CLANG_REPORTED_VERSION >= 50000 +# define BOOST_CLANG_VERSION 30300 + +# elif BOOST_CLANG_REPORTED_VERSION >= 40200 +# define BOOST_CLANG_VERSION 30200 + +# elif BOOST_CLANG_REPORTED_VERSION >= 30100 +# define BOOST_CLANG_VERSION 30100 + +# elif BOOST_CLANG_REPORTED_VERSION >= 20100 +# define BOOST_CLANG_VERSION 30000 + +# else +# define BOOST_CLANG_VERSION 20900 + +# endif + +# undef BOOST_CLANG_REPORTED_VERSION +#endif diff --git a/include/boost/config/compiler/xlcpp.hpp b/include/boost/config/compiler/xlcpp.hpp index c24b2c51..6e868817 100644 --- a/include/boost/config/compiler/xlcpp.hpp +++ b/include/boost/config/compiler/xlcpp.hpp @@ -288,3 +288,4 @@ // Macro used to identify the Clang compiler. #define BOOST_CLANG 1 +#define BOOST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) From 1e63c7729dcf574df29c6702dd0e36fd47aa5f4f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 4 Jul 2021 18:51:25 +0300 Subject: [PATCH 2/6] Define BOOST_CLANG_VERSION_WORKAROUND_GUARD --- include/boost/config/workaround.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/config/workaround.hpp b/include/boost/config/workaround.hpp index 7c6a2e62..37638b4b 100644 --- a/include/boost/config/workaround.hpp +++ b/include/boost/config/workaround.hpp @@ -254,6 +254,12 @@ #else #define BOOST_INTEL_WORKAROUND_GUARD 0 #endif +#ifndef BOOST_CLANG_VERSION +#define BOOST_CLANG_VERSION_WORKAROUND_GUARD 1 +#else +#define BOOST_CLANG_VERSION_WORKAROUND_GUARD 0 +#endif + // Always define to zero, if it's used it'll be defined my MPL: #define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0 From 0148ea5ea2389313a8fa27c698ad34b7932e7335 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 4 Jul 2021 19:08:00 +0300 Subject: [PATCH 3/6] Print BOOST_CLANG, BOOST_CLANG_VERSION in config_info --- test/config_info.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/config_info.cpp b/test/config_info.cpp index ebb98f2b..db9a73e6 100644 --- a/test/config_info.cpp +++ b/test/config_info.cpp @@ -1268,6 +1268,8 @@ void print_boost_macros() PRINT_MACRO(BOOST_INTEL); PRINT_MACRO(BOOST_MSVC); PRINT_MACRO(BOOST_GCC); + PRINT_MACRO(BOOST_CLANG); + PRINT_MACRO(BOOST_CLANG_VERSION); PRINT_MACRO(BOOST_LIBSTDCXX_VERSION); PRINT_MACRO(BOOST_STD_EXTENSION_NAMESPACE); PRINT_MACRO(BOOST_UNREACHABLE_RETURN(0)); From 098ca4a3cf5fe1350043d683182ec46eba3652b1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 4 Jul 2021 19:12:16 +0300 Subject: [PATCH 4/6] Document BOOST_CLANG_VERSION --- doc/macro_reference.qbk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/macro_reference.qbk b/doc/macro_reference.qbk index 729cb5b9..66af3c5c 100644 --- a/doc/macro_reference.qbk +++ b/doc/macro_reference.qbk @@ -1481,6 +1481,12 @@ compiler version macro. [[`BOOST_CLANG`][``][ Defined to 1 if the compiler is the Clang compiler. ]] +[[`BOOST_CLANG_VERSION`][``][ +Defined to the version of the Clang compiler, usually +`__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__`. On +Apple Clang, has a best-effort value reflecting the upstream version, rather +than the Apple version. +]] [[`BOOST_BORLANDC`][``][ Defined to the value of __BORLANDC__ if the compiler is the Embarcadero non-clang based compiler. From 8595667b3636a30ef9e583e3a0387937808da94d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 4 Jul 2021 20:02:20 +0300 Subject: [PATCH 5/6] Fix spelling of __APPLE__ --- include/boost/config/compiler/clang_version.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/config/compiler/clang_version.hpp b/include/boost/config/compiler/clang_version.hpp index c0741e18..9e5b408a 100644 --- a/include/boost/config/compiler/clang_version.hpp +++ b/include/boost/config/compiler/clang_version.hpp @@ -2,7 +2,7 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt) -#if !defined(__APPLE) +#if !defined(__APPLE__) # define BOOST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) From b80c25f474a44e20a162c49763158eddd8553ac5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 4 Jul 2021 20:06:09 +0300 Subject: [PATCH 6/6] Print __apple_build_version__ in config_info --- test/config_info.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/config_info.cpp b/test/config_info.cpp index db9a73e6..70ddd411 100644 --- a/test/config_info.cpp +++ b/test/config_info.cpp @@ -380,6 +380,7 @@ void print_compiler_macros() PRINT_MACRO(__clang_minor__); PRINT_MACRO(__clang_version__); PRINT_MACRO(__clang_patchlevel__); + PRINT_MACRO(__apple_build_version__); // misc compilers not covered so far: PRINT_MACRO(__USLC__);