Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-31 12:52:41 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-31 13:00:31 +0300
commitfdb83d98f75ff990bcc6ac374eca9804d4cda5ee (patch)
treeebedaf9f54a83984d6ff62134405cc847a26c5c3 /source/blender/blenlib/BLI_assert.h
parent8d95dcd87dbb5775236126e61fcc5c2ac951ca0f (diff)
Cleanup: simplify static assert definitions, assuming C11 and C++11
Diffstat (limited to 'source/blender/blenlib/BLI_assert.h')
-rw-r--r--source/blender/blenlib/BLI_assert.h37
1 files changed, 13 insertions, 24 deletions
diff --git a/source/blender/blenlib/BLI_assert.h b/source/blender/blenlib/BLI_assert.h
index b517fcba0dc..6942c87caec 100644
--- a/source/blender/blenlib/BLI_assert.h
+++ b/source/blender/blenlib/BLI_assert.h
@@ -84,32 +84,21 @@ extern "C" {
# define BLI_assert(a) ((void)0)
#endif
-// A Clang feature extension to determine compiler features.
-#ifndef __has_feature
-# define __has_feature(x) 0
-#endif
-
-/* C++ can't use _Static_assert, expects static_assert() but c++0x only,
- * Coverity also errors out. */
-#if (!defined(__cplusplus)) && (!defined(__COVERITY__)) && \
- ((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || \
- (defined(__clang__) && __has_feature(c_static_assert))) /* GCC 4.6+ and clang */
-# define BLI_STATIC_ASSERT(a, msg) __extension__ _Static_assert(a, msg);
+#if defined(__cplusplus)
+/* C++11 */
+# define BLI_STATIC_ASSERT(a, msg) static_assert(a, msg);
#elif defined(_MSC_VER)
+/* Visual Studio */
# define BLI_STATIC_ASSERT(a, msg) _STATIC_ASSERT(a);
-#else /* older gcc, clang... */
-/* Code adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html */
-/* Note we need the two concats below because arguments to ## are not expanded, so we need to
- * expand __LINE__ with one indirection before doing the actual concatenation. */
-# define _BLI_ASSERT_CONCAT_(a, b) a##b
-# define _BLI_ASSERT_CONCAT(a, b) _BLI_ASSERT_CONCAT_(a, b)
-/* This can't be used twice on the same line so ensure if using in headers
- * that the headers are not included twice (by wrapping in #ifndef...#endif)
- * Note it doesn't cause an issue when used on same line of separate modules
- * compiled with gcc -combine -fwhole-program. */
-# define BLI_STATIC_ASSERT(a, msg) \
- ; \
- enum { _BLI_ASSERT_CONCAT(assert_line_, __LINE__) = 1 / (int)(!!(a)) };
+#elif defined(__COVERITY__)
+/* Workaround error with coverity */
+# define BLI_STATIC_ASSERT(a, msg)
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+/* C11 */
+# define BLI_STATIC_ASSERT(a, msg) _Static_assert(a, msg);
+#else
+/* Old unsupported compiler */
+# define BLI_STATIC_ASSERT(a, msg)
#endif
#define BLI_STATIC_ASSERT_ALIGN(st, align) \