introduce c11_compat.h to provide C11 things in C99
authorEric Engestrom <eric.engestrom@intel.com>
Tue, 23 Jul 2019 12:44:33 +0000 (13:44 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Sun, 4 Aug 2019 10:14:25 +0000 (11:14 +0100)
Right now, all it does is provide the new standard `static_assert()` name.

Fixes: fbf7c38da35afe7f1de0 ("egl/wayland: use bitset.h for `formats` bit set")
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Tested-by: Bhushan Shah <bshah@kde.org>
include/c11_compat.h [new file with mode: 0644]
src/util/macros.h

diff --git a/include/c11_compat.h b/include/c11_compat.h
new file mode 100644 (file)
index 0000000..d35740f
--- /dev/null
@@ -0,0 +1,27 @@
+/* Copyright 2019 Intel Corporation */
+/* SPDX-License-Identifier: MIT */
+
+#include "no_extern_c.h"
+
+#ifndef _C11_COMPAT_H_
+#define _C11_COMPAT_H_
+
+#if defined(__cplusplus)
+   /* This is C++ code, not C */
+#elif (__STDC_VERSION__ >= 201112L)
+   /* Already C11 */
+#else
+
+
+/*
+ * C11 static_assert() macro
+ * assert.h only defines that name for C11 and above
+ */
+#ifndef static_assert
+#define static_assert _Static_assert
+#endif
+
+
+#endif /* !C++ && !C11 */
+
+#endif /* _C11_COMPAT_H_ */
index 86585f609da503565a94042a00d19f17086a6aa9..f5f099bb594443f25233b195e04bd148eefeeab6 100644 (file)
@@ -27,6 +27,7 @@
 #include <assert.h>
 
 #include "c99_compat.h"
+#include "c11_compat.h"
 
 /* Compute the size of an array */
 #ifndef ARRAY_SIZE