summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-04-11 15:43:54 +0000
committerfrosch <frosch@openttd.org>2010-04-11 15:43:54 +0000
commit03c609f019f437f4fb7e252a2345d4b62ab930e8 (patch)
tree8e3ab9ffb4afcc012e158eb56cb14c85c2bc760d
parent5c7aaf11badc8be299ca4fe3c1b988d49a237d74 (diff)
downloadopenttd-03c609f019f437f4fb7e252a2345d4b62ab930e8.tar.xz
(svn r19604) -Codechange: Reintroduce assert_tcompile().
-rw-r--r--src/stdafx.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/stdafx.h b/src/stdafx.h
index 854282b6c..25973dea6 100644
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -313,15 +313,20 @@ typedef unsigned char byte;
#define PERSONAL_DIR ""
#endif
-/* Compile time assertions. Prefer c++0x static_assert() */
+/* Compile time assertions. Prefer c++0x static_assert().
+ * Older compilers cannot evaluate some expressions at compile time,
+ * typically when templates are involved, try assert_tcompile() in those cases. */
#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 )
+ #define assert_tcompile(expr) assert_compile(expr)
#elif defined(__OS2__)
/* Disabled for OS/2 */
#define assert_compile(expr)
+ #define assert_tcompile(expr) assert_compile(expr)
#else
#define assert_compile(expr) typedef int __ct_assert__[1 - 2 * !(expr)]
+ #define assert_tcompile(expr) assert(expr)
#endif
/* Check if the types have the bitsizes like we are using them */