[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
obstack, libc-config: Support HP-UX cc in C99 mode
From: |
Bruno Haible |
Subject: |
obstack, libc-config: Support HP-UX cc in C99 mode |
Date: |
Sun, 16 Dec 2018 10:47:12 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-139-generic; KDE/5.18.0; x86_64; ; ) |
Testing a 'grep' snapshot on HP-UX 11.31 hppa, in 32-bit mode,
with cc (as I don't have a gcc on that machine), more precisely
CC="cc -AC99 -D_XOPEN_SOURCE=500", I get this compilation error:
CC obstack.o
cc: "../../lib/obstack.h", line 175: error 1687: Illegal use of flexible array:
structs with FAMs cannot be members of other structs.
cc: "../../lib/obstack.c", line 139: warning 521: Incompatible pointer types.
cc: "../../lib/obstack.c", line 204: warning 604: Pointers are not
assignment-compatible.
cc: "../../lib/obstack.c", line 209: warning 521: Incompatible pointer types.
cc: "../../lib/obstack.c", line 219: warning 521: Incompatible pointer types.
cc: "../../lib/obstack.c", line 252: warning 604: Pointers are not
assignment-compatible.
cc: "../../lib/obstack.c", line 273: warning 604: Pointers are not
assignment-compatible.
cc: "../../lib/obstack.c", line 297: warning 604: Pointers are not
assignment-compatible.
gmake[2]: *** [obstack.o] Error 1
The reason is that __STDC_VERSION__ expands to 199901L; however, the
compiler apparently has bugs regarding flexible-array-members.
This is a regression from 2016-11-15.
This patch fixes it (and other occurrences of the same idiom in other files
as well):
2018-12-16 Bruno Haible <address@hidden>
obstack, libc-config: Support HP-UX cc in C99 mode.
* lib/obstack.h (__FLEXIBLE_ARRAY_MEMBER): Treat HP-UX cc as a pre-C99
compiler, even when in C99 mode.
* lib/cdefs.h (__flexarr): Likewise.
* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Update comment.
diff --git a/lib/obstack.h b/lib/obstack.h
index ed95cce..4a89331 100644
--- a/lib/obstack.h
+++ b/lib/obstack.h
@@ -111,7 +111,7 @@
#include <stddef.h> /* For size_t and ptrdiff_t. */
#include <string.h> /* For __GNU_LIBRARY__, and memcpy. */
-#if __STDC_VERSION__ < 199901L
+#if __STDC_VERSION__ < 199901L || defined __HP_cc
# define __FLEXIBLE_ARRAY_MEMBER 1
#else
# define __FLEXIBLE_ARRAY_MEMBER
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 98cf749..26e2f3f 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -139,7 +139,7 @@
Headers that should use flexible arrays only if they're "real"
(e.g. only if they won't affect sizeof()) should test
#if __glibc_c99_flexarr_available. */
-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
# define __flexarr []
# define __glibc_c99_flexarr_available 1
#elif __GNUC_PREREQ (2,97)
diff --git a/lib/gettext.h b/lib/gettext.h
index 27c754c..d5d56ec 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -185,7 +185,7 @@ npgettext_aux (const char *domain,
#include <string.h>
#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
- /* || __STDC_VERSION__ == 199901L
+ /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
|| (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- obstack, libc-config: Support HP-UX cc in C99 mode,
Bruno Haible <=