[PATCH libinput] Switch to _Static_assert from static_assert and make sure it exists
Jonas Ådahl
jadahl at gmail.com
Mon May 16 02:02:03 UTC 2016
On Mon, May 16, 2016 at 11:46:28AM +1000, Peter Hutterer wrote:
> _Static_assert is the C keyword, the lowercase version is the C++ one.
> Add the required configure.ac bits if this is missing.
static_assert isn't just C++, it's, just as _Static_assert, part of C11,
except that it is, just as assert, defined as a macro in assert.h, and
not as a keyword. So, using static_assert is equally correct and IMHO
also aesthetically more pleasing.
Either way, the patch content looks correct, so if either the commit
message is corrected, or the patch is changed to just check for
static_assert instead of checking and changing to _Static_assert, this
is Reviewed-by: Jonas Ådahl <jadahl at gmail.com>.
Jonas
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> configure.ac | 6 ++++++
> src/evdev-tablet.c | 2 +-
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index 8ddc3b6..cfbe024 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -60,6 +60,12 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
> [AC_MSG_ERROR("CLOCK_MONOTONIC is needed to compile libinput")],
> [[#include <time.h>]])
>
> +AC_MSG_CHECKING([whether _Static_assert() is supported])
> +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
> + [AC_MSG_RESULT([yes])],
> + [AC_DEFINE(_Static_assert(...), [/* */], [Noop _Static_assert() replacement])
> + AC_MSG_RESULT([no])])
> +
> PKG_PROG_PKG_CONFIG()
> PKG_CHECK_MODULES(MTDEV, [mtdev >= 1.1.0])
> PKG_CHECK_MODULES(LIBUDEV, [libudev])
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 4e8b920..89340bd 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -1187,7 +1187,7 @@ static void
> tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
> struct libinput_tablet_tool *tool)
> {
> - static_assert(sizeof(tablet->changed_axes) ==
> + _Static_assert(sizeof(tablet->changed_axes) ==
> sizeof(tool->axis_caps),
> "Mismatching array sizes");
>
> --
> 2.7.4
>
More information about the wayland-devel
mailing list