helpers: Move static_assert definition to shared

Collect the fallback definitions of static_assert() from desktop-shell
and the test shell, and move them to helpers.h. This allows code
throughout the tree to use static_assert() for build-time assertions,
where it is supported by the compiler.

As GCC goes out of its way to only add static_assert() when C11 has been
explicitly requested - which we don't do - make sure to use the more
widely available _Static_assert() if that is provided.

This will be used in future patches to ensure two array lengths don't go
out of sync.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Daniel Stone
2018-07-09 13:05:59 +01:00
parent bdebc3170e
commit 11f91bbd36
3 changed files with 34 additions and 8 deletions
-4
View File
@@ -41,10 +41,6 @@
#include "shared/helpers.h"
#include "libweston-desktop/libweston-desktop.h"
#ifndef static_assert
#define static_assert(cond, msg)
#endif
struct desktest_shell {
struct wl_listener compositor_destroy_listener;
struct weston_desktop *desktop;