util: Allow STATIC_ASSERT() everywhere
Remove -Werror=vla from c_msvc_compat_args so we can use STATIC_ASSERT() in core code. We have a CI job for this. (And arguably we could probably just drop c_msvc_compat_args entirely.) Signed-off-by: Rob Clark <robdclark@chromium.org> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7941>
This commit is contained in:
@@ -66,13 +66,26 @@
|
||||
|
||||
/**
|
||||
* Static (compile-time) assertion.
|
||||
* Basically, use COND to dimension an array. If COND is false/zero the
|
||||
* array size will be -1 and we'll get a compilation error.
|
||||
*/
|
||||
#define STATIC_ASSERT(COND) \
|
||||
do { \
|
||||
#if defined(_MSC_VER)
|
||||
/* MSVC doesn't like VLA's, but it also dislikes zero length arrays
|
||||
* (which gcc is happy with), so we have to define STATIC_ASSERT()
|
||||
* slightly differently.
|
||||
*/
|
||||
# define STATIC_ASSERT(COND) do { \
|
||||
(void) sizeof(char [(COND) != 0]); \
|
||||
} while (0)
|
||||
#elif defined(__GNUC__)
|
||||
/* This version of STATIC_ASSERT() relies on VLAs. If COND is
|
||||
* false/zero, the array size will be -1 and we'll get a compile
|
||||
* error
|
||||
*/
|
||||
# define STATIC_ASSERT(COND) do { \
|
||||
(void) sizeof(char [1 - 2*!(COND)]); \
|
||||
} while (0)
|
||||
#else
|
||||
# define STATIC_ASSERT(COND) do { } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user