Yesterday I did:
>       string-desc: Revisit feature tests regarding C++.
>       * lib/string-desc.h (HAVE_STATEMENT_EXPRESSIONS): Also define with
>       SunPRO C++.
>       (HAVE__GENERIC): Don't define with GNU C++. Define in ISO C 11 or newer.

But the CI reports that this leads to a compilation error on CentOS 7:

gcc -std=gnu11 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC 
-DEXEEXT=\"\" -I. -I../../gllib -I..  -DGNULIB_STRICT_CHECKING=1 -Wall 
-DCONTINUE_AFTER_ASSERT -fvisibility=hidden -g -O2 -MT sf-istream.o -MD -MP -MF 
$depbase.Tpo -c -o sf-istream.o ../../gllib/sf-istream.c &&\
mv -f $depbase.Tpo $depbase.Po
../../gllib/sf-istream.c: In function 'sf_istream_init_from_string_desc':
../../gllib/sf-istream.c:49:3: warning: implicit declaration of function 
'_Generic' [-Wimplicit-function-declaration]
   stream->input = sd_data (input);
   ^
In file included from ../../gllib/sf-istream.h:24:0,
                 from ../../gllib/sf-istream.c:22:
../../gllib/string-desc.h:404:14: error: expected expression before 
'string_desc_t'
              string_desc_t    : (s)._data, \
              ^
../../gllib/sf-istream.c:49:19: note: in expansion of macro 'sd_data'
   stream->input = sd_data (input);
                   ^
../../gllib/string-desc.h:364:14: error: expected expression before 
'string_desc_t'
              string_desc_t    : (s)._nbytes, \
              ^
../../gllib/sf-istream.c:50:39: note: in expansion of macro 'sd_length'
   stream->input_end = stream->input + sd_length (input);
                                       ^
make[4]: *** [sf-istream.o] Error 1

Apparently gcc 4.8.5, with option -std=gnu11, reports ISO C11 compliance
without implementing _Generic.


2026-01-12  Bruno Haible  <[email protected]>

        string-desc: Fix compilation error with gcc 4.8.x (regr. yesterday).
        * lib/string-desc.h (HAVE__GENERIC): Ignore __STDC_VERSION__ for GCC.

diff --git a/lib/string-desc.h b/lib/string-desc.h
index 24c38ccf35..a3c17b8fdd 100644
--- a/lib/string-desc.h
+++ b/lib/string-desc.h
@@ -56,7 +56,7 @@
 #if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined 
__cplusplus) /* C mode */ \
     || (defined __clang__ && __clang_major__ >= 3) /* both C and C++ mode */ \
     || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150) /* C mode */ \
-    || __STDC_VERSION__ >= 201112L /* C mode */
+    || (__STDC_VERSION__ >= 201112L && !defined __GNUC__) /* C mode */
 # define HAVE__GENERIC 1
 #endif
 




Reply via email to