aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-04-07 11:48:28 -0700
committerChris Robinson <[email protected]>2014-04-07 11:48:28 -0700
commitc6821e5dd177a0d5e36047de8a107bc650ae8725 (patch)
treec9d4d88c6c834459c93c7c71eaffe773b3c016b1 /OpenAL32
parentf1a4b95b8cf483316025d95727b56da736546ccf (diff)
Use C11's static_assert when available
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h12
-rw-r--r--OpenAL32/sample_cvt.c4
2 files changed, 14 insertions, 2 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 501d2a81..3247aa96 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -20,6 +20,18 @@
#include "AL/alc.h"
#include "AL/alext.h"
+
+#ifndef static_assert
+#ifdef HAVE_C11_STATIC_ASSERT
+#define static_assert _Static_assert
+#else
+#define CTASTR2(_pre,_post) _pre##_post
+#define CTASTR(_pre,_post) CTASTR2(_pre,_post)
+#define static_assert(_cond, _msg) typedef struct { int CTASTR(static_assert_failed_at_line_,__LINE__) : !!(_cond); } CTASTR(static_assertion_,__COUNTER__)
+#endif
+#endif
+
+
#include "atomic.h"
#include "uintmap.h"
#include "vector.h"
diff --git a/OpenAL32/sample_cvt.c b/OpenAL32/sample_cvt.c
index 903ec8ca..7ea4180e 100644
--- a/OpenAL32/sample_cvt.c
+++ b/OpenAL32/sample_cvt.c
@@ -177,11 +177,11 @@ typedef ALubyte ALmsadpcm;
typedef struct {
ALbyte b[3];
} ALbyte3;
-extern ALbyte ALbyte3_size_is_not_3[(sizeof(ALbyte3)==sizeof(ALbyte[3]))?1:-1];
+static_assert(sizeof(ALbyte3)==sizeof(ALbyte[3]), "ALbyte3 size is not 3");
typedef struct {
ALubyte b[3];
} ALubyte3;
-extern ALbyte ALubyte3_size_is_not_3[(sizeof(ALubyte3)==sizeof(ALubyte[3]))?1:-1];
+static_assert(sizeof(ALubyte3)==sizeof(ALubyte[3]), "ALubyte3 size is not 3");
static inline ALshort DecodeMuLaw(ALmulaw val)
{ return muLawDecompressionTable[val]; }