summaryrefslogtreecommitdiff
path: root/src/stdafx.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-09-07 21:02:10 +0000
committersmatz <smatz@openttd.org>2009-09-07 21:02:10 +0000
commit2e2d00bee7291156b9ff963b71abf3b177563869 (patch)
tree02f0e3d1973e6ce6f58ea46520a1617adc69f959 /src/stdafx.h
parent434693b8389a5816d73f089e064819a19f76f798 (diff)
downloadopenttd-2e2d00bee7291156b9ff963b71abf3b177563869.tar.xz
(svn r17465) -Codechange: use builtin static_assert() for assert_compile() if available
Diffstat (limited to 'src/stdafx.h')
-rw-r--r--src/stdafx.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/stdafx.h b/src/stdafx.h
index f21b28ee9..2dab7c0ae 100644
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -301,12 +301,16 @@ typedef unsigned char byte;
#define PERSONAL_DIR ""
#endif
-/* Compile time assertions, disabled for OS/2 or GCC < 3.4 (GCC < 3 isn't supported anymore) */
-#if defined(__OS2__) || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4)
+/* Compile time assertions. Prefer c++0x static_assert() */
+#if defined(__STDCXX_VERSION__) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) || defined(static_assert)
+ /* __STDCXX_VERSION__ is c++0x feature macro, __GXX_EXPERIMENTAL_CXX0X__ is used by gcc, __GXX_EXPERIMENTAL_CPP0X__ by icc */
+ #define assert_compile(expr) static_assert(expr, #expr )
+#elif defined(__OS2__) || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4)
+ /* Disabled for OS/2 or GCC < 3.4 (GCC < 3 isn't supported anymore) */
#define assert_compile(expr)
#else
#define assert_compile(expr) extern const int __ct_assert__[1 - 2 * !(expr)] UNUSED
-#endif /* __OS2__ */
+#endif
/* Check if the types have the bitsizes like we are using them */
assert_compile(sizeof(uint64) == 8);