From b98b00281c963b3c9c0ae4793d2df88fc2ee8778 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 12 Apr 2017 08:30:23 +0000 Subject: [PATCH] compat.h: Add macros so that we can use constexpr without breaking C++ < 11 and C. git-svn-id: https://svn.eduke32.com/eduke32@6115 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/compat.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 32c290176..1b4bde628 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -190,6 +190,18 @@ # define ASMSYM(x) x #endif +#if defined __cplusplus && (__cplusplus >= 201103L || __has_feature(cxx_constexpr)) +# define HAVE_CONSTEXPR +# define CONSTEXPR constexpr +#else +# define CONSTEXPR +#endif + +#if CXXSTD >= 2014 +# define CONSTEXPR_CXX14 CONSTEXPR +#else +# define CONSTEXPR_CXX14 +#endif ////////// Platform detection ////////// @@ -663,7 +675,7 @@ EDUKE32_STATIC_ASSERT(sizeof(vec3d_t) == sizeof(double) * 3); #if defined _MSC_VER # define ARRAY_SIZE(arr) _countof(arr) -#elif defined __cplusplus && (__cplusplus >= 201103L || __has_feature(cxx_constexpr)) +#elif defined HAVE_CONSTEXPR template static FORCE_INLINE constexpr size_t ARRAY_SIZE(T const (&)[N]) noexcept {