Skip to content

Commit

Permalink
Cleanup version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jan 12, 2024
1 parent fd87a23 commit b8429a5
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,42 @@
// The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 100202

// Detect compiler versions.
#if defined(__clang__) && !defined(__ibmxl__)
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
#else
# define FMT_CLANG_VERSION 0
#endif

#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
!defined(__NVCOMPILER)
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else
# define FMT_GCC_VERSION 0
#endif

#ifndef FMT_GCC_PRAGMA
// Workaround _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884.
# if FMT_GCC_VERSION >= 504
# define FMT_GCC_PRAGMA(arg) _Pragma(arg)
# else
# define FMT_GCC_PRAGMA(arg)
# endif
#endif

#ifdef __ICL
#if defined(__ICL)
# define FMT_ICC_VERSION __ICL
#elif defined(__INTEL_COMPILER)
# define FMT_ICC_VERSION __INTEL_COMPILER
#else
# define FMT_ICC_VERSION 0
#endif

#ifdef _MSC_VER
#if defined(_MSC_VER)
# define FMT_MSC_VERSION _MSC_VER
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
#else
# define FMT_MSC_VERSION 0
# define FMT_MSC_WARNING(...)
#endif

// Detect standard library versions.
#ifdef _GLIBCXX_RELEASE
# define FMT_GLIBCXX_RELEASE _GLIBCXX_RELEASE
#else
# define FMT_GLIBCXX_RELEASE 0
#endif
#ifdef _LIBCPP_VERSION
# define FMT_LIBCPP_VERSION _LIBCPP_VERSION
#else
# define FMT_LIBCPP_VERSION 0
#endif

#ifdef _MSVC_LANG
# define FMT_CPLUSPLUS _MSVC_LANG
Expand Down Expand Up @@ -126,7 +119,7 @@
#if (FMT_CPLUSPLUS >= 202002L || \
(FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \
((!FMT_GLIBCXX_RELEASE || FMT_GLIBCXX_RELEASE >= 10) && \
(!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 10000) && \
(!FMT_LIBCPP_VERSION || FMT_LIBCPP_VERSION >= 10000) && \
(!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1928)) && \
defined(__cpp_lib_is_constant_evaluated)
# define FMT_CONSTEXPR20 constexpr
Expand Down Expand Up @@ -175,6 +168,20 @@
# define FMT_INLINE inline
#endif

#ifndef FMT_GCC_PRAGMA
// Workaround _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884.
# if FMT_GCC_VERSION >= 504
# define FMT_GCC_PRAGMA(arg) _Pragma(arg)
# else
# define FMT_GCC_PRAGMA(arg)
# endif
#endif
#if FMT_MSC_VERSION
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
#else
# define FMT_MSC_WARNING(...)
#endif

#ifdef _MSC_VER
# define FMT_UNCHECKED_ITERATOR(It) \
using _Unchecked_type = It // Mark iterator as checked.
Expand Down

0 comments on commit b8429a5

Please sign in to comment.