immutable: Add tests.
[gnulib.git] / m4 / assert_h.m4
blob40bb0ea0f43f8ba10a09b0d563a6b0d8fd7f1faf
1 # assert-h.m4
2 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl From Paul Eggert.
9 AC_DEFUN([gl_ASSERT_H],
11   ASSERT_H=
12   AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert],
13     [AC_COMPILE_IFELSE(
14        [AC_LANG_PROGRAM(
15           [[#include <assert.h>
16             static_assert (2 + 2 == 4, "arithmetic doesn't work");
17             static_assert (2 + 2 == 4);
18           ]],
19           [[
20             static_assert (sizeof (char) == 1, "sizeof doesn't work");
21             static_assert (sizeof (char) == 1);
22           ]])],
23        [gl_cv_static_assert=yes],
24        [gl_cv_static_assert=no])])
25   if test $gl_cv_static_assert = no; then
26     ASSERT_H=assert.h
27     gl_NEXT_HEADERS([assert.h])
28   fi
29   AC_SUBST([ASSERT_H])
30   AM_CONDITIONAL([GL_GENERATE_ASSERT_H], [test -n "$ASSERT_H"])