bug-gnulib
[Top][All Lists]
Advanced

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

assert-h: Fix test compilation error on IRIX 6.5


From: Bruno Haible
Subject: assert-h: Fix test compilation error on IRIX 6.5
Date: Wed, 08 Feb 2023 22:36:46 +0100

On IRIX 6.5, with gcc, I'm seeing this compilation error:

../../gltests/test-assert.c: In function `g':
../../gltests/test-assert.c:48: error: too few arguments to function `assert'
../../gltests/test-assert.c: In function `h':
../../gltests/test-assert.c:60: error: too few arguments to function `assert'
gmake[2]: *** [Makefile:3543: test-assert.o] Error 1

The cause is that config.h includes <assert.h>, then undefines 'assert',
and then a later '#include <assert.h>' is a no-op.

This error must have been present since this unit test was added, on 2022-09-13.

This patch fixes it.


2023-02-08  Bruno Haible  <bruno@clisp.org>

        assert-h: Fix test failure on IRIX 6.5.
        * m4/assert_h.m4 (gl_ASSERT_H): Ensure that on IRIX, including
        <assert.h> after <config.h> actually defines the assert macro.

diff --git a/m4/assert_h.m4 b/m4/assert_h.m4
index 3801452ef0..d255855d31 100644
--- a/m4/assert_h.m4
+++ b/m4/assert_h.m4
@@ -46,10 +46,13 @@ AC_DEFUN([gl_ASSERT_H],
        gl_NEXT_HEADERS([assert.h])])
 
   dnl The "zz" puts this toward config.h's end, to avoid potential
-  dnl collisions with other definitions.  #undef assert so that
-  dnl programs are not tempted to use it without specifically
-  dnl including assert.h.  Break the #undef apart with a comment
-  dnl so that 'configure' does not comment it out.
+  dnl collisions with other definitions.
+  dnl #undef assert so that programs are not tempted to use it without
+  dnl specifically including assert.h.
+  dnl #undef __ASSERT_H__ so that on IRIX, when programs later include
+  dnl <assert.h>, this include actually defines assert.
+  dnl Break the #undef_s apart with a comment so that 'configure' does
+  dnl not comment them out.
   AH_VERBATIM([zzstatic_assert],
 [#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \
      && (!defined __cplusplus \
@@ -57,6 +60,9 @@ AC_DEFUN([gl_ASSERT_H],
              && __GNUG__ < 6 && __clang_major__ < 6)))
  #include <assert.h>
  #undef/**/assert
+ #ifdef __sgi
+  #undef/**/__ASSERT_H__
+ #endif
  /* 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






reply via email to

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