diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-05-31 15:09:48 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-05-31 15:09:48 +0300 |
commit | ed17d250081968090368329c3185242233569d61 (patch) | |
tree | 570bee4c15dfe55ec4e1305e3816543f17eaa503 /source/blender/blenlib | |
parent | 18be4b8866d33b753a0fb9d6971249f1fe5e262d (diff) | |
parent | aec28acc751727c9a5a70482b2b9d0800ee2cf47 (diff) |
Merge remote-tracking branch 'origin/master' into soc-2019-cycles-procedural
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_assert.h | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_assert.h b/source/blender/blenlib/BLI_assert.h index 3d3c84d6370..6942c87caec 100644 --- a/source/blender/blenlib/BLI_assert.h +++ b/source/blender/blenlib/BLI_assert.h @@ -84,26 +84,21 @@ extern "C" { # define BLI_assert(a) ((void)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)) /* gcc4.6+ only */ -# 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) \ |