compat.h: Add some definitions for easy testing of language standard versions.

git-svn-id: https://svn.eduke32.com/eduke32@6114 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-04-12 08:30:18 +00:00
parent 0c31245cd2
commit 1ebbd553bd

View file

@ -32,6 +32,33 @@
#endif
////////// Language detection //////////
#if defined __STDC__
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
# define CSTD 2011
# elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define CSTD 1999
# elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L
# define CSTD 1994
# else
# define CSTD 1989
# endif
#else
# define CSTD 0
#endif
#if defined __cplusplus && __cplusplus >= 201402L
# define CXXSTD 2014
#elif defined __cplusplus && __cplusplus >= 201103L
# define CXXSTD 2011
#elif defined __cplusplus && __cplusplus >= 199711L
# define CXXSTD 1998
#else
# define CXXSTD 0
#endif
////////// Language and compiler feature polyfills //////////
#ifdef __cplusplus
@ -122,7 +149,7 @@
#if EDUKE32_GCC_PREREQ(2,0) || defined _MSC_VER
# define EDUKE32_FUNCTION __FUNCTION__
#elif (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || (defined __cplusplus && __cplusplus >= 201103L)
#elif CSTD >= 1999 || CXXSTD >= 2011
# define EDUKE32_FUNCTION __func__
#else
# define EDUKE32_FUNCTION "???"