From 23e39b56dcae55d13673abb57f263a82a2d40549 Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Sun, 20 May 2007 14:24:54 +0000 Subject: [PATCH] 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 --- lib/framework/debug.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/framework/debug.h b/lib/framework/debug.h index 604eed600..ce849144a 100644 --- a/lib/framework/debug.h +++ b/lib/framework/debug.h @@ -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 /***