bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

assert-h: Make static_assert work on Solaris 11.4


From: Bruno Haible
Subject: assert-h: Make static_assert work on Solaris 11.4
Date: Sun, 23 Oct 2022 16:47:12 +0200

The GNU sed prerelease testing [1] and the GNU texinfo prerelease testing [2]
have revealed compilation errors on Solaris 11.4, due to the use of
'static_assert'. The <assert.h> of Solaris 11.4 defines it in such a way
that it can only be invoked with 2 arguments. However, since 2022-09-13,
many Gnulib source files use 'static_assert' with 1 argument only.

[1] https://lists.gnu.org/archive/html/sed-devel/2022-10/msg00004.html
[2] https://lists.gnu.org/archive/html/bug-texinfo/2022-10/msg00188.html

This patch fixes it.


2022-10-23  Bruno Haible  <bruno@clisp.org>

        assert-h: Make static_assert work on Solaris 11.4.
        * m4/assert_h.m4 (gl_ASSERT_H): After including <assert.h>, on Solaris,
        redefine static_assert.

diff --git a/m4/assert_h.m4 b/m4/assert_h.m4
index c1306daef4..e892ea2f01 100644
--- a/m4/assert_h.m4
+++ b/m4/assert_h.m4
@@ -57,5 +57,11 @@ AC_DEFUN([gl_ASSERT_H],
              && __GNUG__ < 6 && __clang_major__ < 6)))
  #include <assert.h>
  #undef/**/assert
+ /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
+    We need it also to be invocable with a single argument.  */
+ #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
+  #undef static_assert
+  #define static_assert _Static_assert
+ #endif
 #endif])
 ])






reply via email to

[Prev in Thread] Current Thread [Next in Thread]