mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
compat.h: Use C++17, C++11, or C11 static_assert if available.
git-svn-id: https://svn.eduke32.com/eduke32@6472 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4966b0922d
commit
dfb98028f1
1 changed files with 13 additions and 6 deletions
|
@ -188,15 +188,22 @@
|
||||||
# define EDUKE32_PRETTY_FUNCTION EDUKE32_FUNCTION
|
# define EDUKE32_PRETTY_FUNCTION EDUKE32_FUNCTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Static assertions, based on source found in LuaJIT's src/lj_def.h. */
|
|
||||||
#define EDUKE32_ASSERT_NAME2(name, line) name ## line
|
|
||||||
#define EDUKE32_ASSERT_NAME(line) EDUKE32_ASSERT_NAME2(eduke32_assert_, line)
|
|
||||||
#ifdef __COUNTER__
|
#ifdef __COUNTER__
|
||||||
# define EDUKE32_STATIC_ASSERT(cond) \
|
# define EDUKE32_UNIQUE_SRC_ID __COUNTER__
|
||||||
extern void EDUKE32_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
|
||||||
#else
|
#else
|
||||||
|
# define EDUKE32_UNIQUE_SRC_ID __LINE__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CXXSTD >= 2017
|
||||||
|
# define EDUKE32_STATIC_ASSERT(cond) static_assert(cond)
|
||||||
|
#elif CXXSTD >= 2011 || CSTD >= 2011 || EDUKE32_MSVC_CXX_PREREQ(1600)
|
||||||
|
# define EDUKE32_STATIC_ASSERT(cond) static_assert(cond, "")
|
||||||
|
#else
|
||||||
|
/* C99 / C++03 static assertions based on source found in LuaJIT's src/lj_def.h. */
|
||||||
|
# define EDUKE32_ASSERT_NAME2(name, line) name ## line
|
||||||
|
# define EDUKE32_ASSERT_NAME(line) EDUKE32_ASSERT_NAME2(eduke32_assert_, line)
|
||||||
# define EDUKE32_STATIC_ASSERT(cond) \
|
# define EDUKE32_STATIC_ASSERT(cond) \
|
||||||
extern void EDUKE32_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
extern void EDUKE32_ASSERT_NAME(EDUKE32_UNIQUE_SRC_ID)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
Loading…
Reference in a new issue