helpers: Move static_assert definition to shared
authorDaniel Stone <daniels@collabora.com>
Mon, 9 Jul 2018 12:05:59 +0000 (13:05 +0100)
committerDaniel Stone <daniels@collabora.com>
Mon, 9 Jul 2018 14:39:20 +0000 (15:39 +0100)
commit11f91bbd36e7ebdc01fb6c2b29bcab53aec7209e
tree3152b5d85ead447d4dc8e4dd77af58ebdf695b2a
parentbdebc3170e5816d6e2d34b36d4643c53634a0e41
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>
desktop-shell/shell.c
shared/helpers.h
tests/weston-test-desktop-shell.c