[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
compiler flags for HP-UX cc
From: |
Bruno Haible |
Subject: |
compiler flags for HP-UX cc |
Date: |
Sat, 20 Dec 2008 13:21:13 +0100 |
User-agent: |
KMail/1.9.9 |
Hi,
The INSTALL file recommends to use "cc -Ae" or "cc -Aa -D_HPUX_SOURCE" on
HP-UX, so that system headers define all needed types and function
declarations.
This is not enough. On HP-UX 11.11 the 'mbstate_t' type is not defined by
<wchar.h>, unless the _XOPEN_SOURCE flag is set to exactly 500.
$ uname -srm
HP-UX B.11.11 9000/785
$ cat > foo.c
#include <wchar.h>
int dummy;
mbstate_t state;
$ cc -Ae -c foo.c
cc: "foo.c", line 3: error 1000: Unexpected symbol: "state".
cc: "foo.c", line 3: warning 557: Missing declaration specifiers, "int" assumed.
$ cc -Ae -D_XOPEN_SOURCE=500 -c foo.c
$ cc -D_HPUX_SOURCE -c foo.c
cc: "foo.c", line 3: error 1000: Unexpected symbol: "state".
cc: "foo.c", line 3: warning 557: Missing declaration specifiers, "int" assumed.
$ cc -D_HPUX_SOURCE -D_XOPEN_SOURCE=500 -c foo.c
$ cc -Aa -D_HPUX_SOURCE -c foo.c
cc: "foo.c", line 3: error 1000: Unexpected symbol: "state".
cc: "foo.c", line 3: warning 557: Missing declaration specifiers, "int" assumed.
$ cc -Aa -D_HPUX_SOURCE -D_XOPEN_SOURCE=500 -c foo.c
Therefore I think autoconf should recommend to set, and itself default to
setting, -D_XOPEN_SOURCE=500. But *only* on HP-UX! The header files of glibc,
MacOS X, FreeBSD, OpenBSD, NetBSD, AIX, IRIX, OSF/1, Solaris, Cygwin, Haiku,
Interix are also sensitive to the _XOPEN_SOURCE flag.
Here is a proposed patch:
2008-12-20 Bruno Haible <address@hidden>
* doc/install.texi (Particular Systems): For HP-UX, also recommend
-D_XOPEN_SOURCE=500. Needed for the declaration of mbstate_t on
HP-UX 11.11.
* lib/autoconf/c.m4 (_AC_PROG_CC_C89): Combine -Aa and -Ae with
-D_XOPEN_SOURCE=500.
--- doc/install.texi.orig 2008-12-20 12:58:46.000000000 +0100
+++ doc/install.texi 2008-12-20 12:57:03.000000000 +0100
@@ -188,7 +188,7 @@
use an ANSI C compiler:
@example
-./configure CC="cc -Ae"
+./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
@end example
@noindent
--- lib/autoconf/c.m4.orig 2008-12-20 12:58:46.000000000 +0100
+++ lib/autoconf/c.m4 2008-12-20 12:58:24.000000000 +0100
@@ -1003,11 +1003,12 @@
dnl AIX circa 2003 -qlanglvl=extc89
dnl old AIX -qlanglvl=ansi
dnl Ultrix, OSF/1, Tru64 -std
-dnl HP-UX 10.20 and later -Ae
-dnl HP-UX older versions -Aa -D_HPUX_SOURCE
+dnl HP-UX 10.20 and later -Ae -D_XOPEN_SOURCE=500
+dnl HP-UX older versions -Aa -D_HPUX_SOURCE -D_XOPEN_SOURCE=500
dnl SVR4 -Xc -D__EXTENSIONS__
[-qlanglvl=extc89 -qlanglvl=ansi -std \
- -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"], [$1], [$2])[]dnl
+ "-Ae -D_XOPEN_SOURCE=500 "-Aa -D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
+ "-Xc -D__EXTENSIONS__"], [$1], [$2])[]dnl
])# _AC_PROG_CC_C89
hpux-predef.diff
Description: Text Data
- compiler flags for HP-UX cc,
Bruno Haible <=