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
This commit is contained in:
hendricks266 2017-04-12 08:30:23 +00:00
parent 1ebbd553bd
commit b98b00281c

View file

@ -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 <typename T, size_t N>
static FORCE_INLINE constexpr size_t ARRAY_SIZE(T const (&)[N]) noexcept
{