From: David Herrmann Date: Sat, 29 Sep 2012 08:13:45 +0000 (+0200) Subject: build: fix compilation if _Static_assert() is not available X-Git-Tag: kmscon-7~460 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=522d2aa2052e0ce16859943ba479cab5b50e04d7;p=platform%2Fupstream%2Fkmscon.git build: fix compilation if _Static_assert() is not available I just noticed that older compiles do not support _Static_assert() so we now check in configure.ac for it. We do not use it heavily, anyway. Dynamic asserts are avoided entirely. Signed-off-by: David Herrmann --- diff --git a/configure.ac b/configure.ac index fdd4205..e0b93b8 100644 --- a/configure.ac +++ b/configure.ac @@ -243,6 +243,17 @@ AM_CONDITIONAL([BUILD_ENABLE_DEBUG], AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS], [test x$optimizations_enabled = xyes]) +# check for _Static_assert +AC_MSG_CHECKING([whether _Static_assert() is supported]) +AC_LANG([C]) +have_static_assert=yes +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Static_assert(1, "What?");]])], + [AC_DEFINE([BUILD_HAVE_STATIC_ASSERT], + [1], + [Define to 1 if _Static_assert() is supported])], + [have_static_assert=no]) +AC_MSG_RESULT([$have_static_assert]) + # # Main applications # This checks which applications to build so we can optionally disable unused diff --git a/src/uterm_input_plain.c b/src/uterm_input_plain.c index 3a7e30c..44de350 100644 --- a/src/uterm_input_plain.c +++ b/src/uterm_input_plain.c @@ -162,10 +162,12 @@ static const uint32_t keytab_normal[] = { #define KEYTAB_SIZE (KEY_RIGHTMETA + 1) +#ifdef BUILD_HAVE_STATIC_ASSERT _Static_assert( (KEYTAB_SIZE == sizeof(keytab_normal) / sizeof(*keytab_normal)), "The KEYTAB_SIZE #define is incorrect!" ); +#endif static const uint32_t keytab_numlock[KEYTAB_SIZE] = { [KEY_KP7] = XKB_KEY_KP_7,