Add a STATIC_ASSERT which also works in global scope.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1665 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2007-05-20 14:24:54 +00:00
parent b620f3f25f
commit 23e39b56dc
1 changed files with 6 additions and 3 deletions

View File

@ -71,11 +71,14 @@ extern char last_called_script_event[MAX_EVENT_NAME_LEN];
/*!
* Compile time assert
* Can not be used in global scope
* \param expr Expression to evaluate
*/
#define ASSERT_STATIC( expr ) \
do { enum { assert_static__ = 1/(expr) }; } while(0)
#define STATIC_ASSERT( expr ) \
extern char MKID(sa, __LINE__, _static_assert)[!!(expr) * 2 - 1]
// Helper macro for STATIC_ASSERT
#define MKID(a, b, c) MKID_(a, b, c)
#define MKID_(a, b, c) a ## b ## c
/***