Hi Eric, > > On HP-UX 11.11, mbstate_t is not defined by <wchar.h> unless _XOPEN_SOURCE > > is > > set to 500. (Even when _HPUX_SOURCE is set!) > > What happens if _XOPEN_SOURCE is set to something larger than 500, > implying a newer standards version?
Then it is as if the flag was not present at all. On HP-UX 11.11, <sys/stdsyms.h> contains: #if defined(_XOPEN_SOURCE) # if (_XOPEN_SOURCE-1+1) == 500 # ifndef _INCLUDE_XOPEN_SOURCE_500 # define _INCLUDE_XOPEN_SOURCE_500 # endif # ifndef _INCLUDE__STDC_A1_SOURCE # define _INCLUDE__STDC_A1_SOURCE # endif ... <wchar.h> contains: # ifdef _INCLUDE__STDC_A1_SOURCE # include <sys/_mbstate_t.h> ... extern int mbsinit __((const mbstate_t *)); > > I have submitted a patch so that autoconf sets this flag by default. But > > there > > are so many INSTALL files which only recommend CC="cc -Ae", that IMO this > > needs to be handled by the gnulib 'extensions' module as well. > > > Ensure mbstate_t is defined on HP-UX 11.11. > > * m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Require > > AC_CANONICAL_HOST. On HP-UX, define _XOPEN_SOURCE to 500. > > This begs the question - should autoconf's AC_USE_SYSTEM_EXTENSIONS also > be doing this, rather than just relying on _AC_PROG_CC_C89? Yes, I believe so, because 1) the user have set CC and CFLAGS himself, or 2) the user might be using CC=gcc, and I don't know whether fixincludes handles this problem. > Also, your proposed patch only touched the C89 tests; what about C99? Indeed. The mbstate_t type and mbsinit etc. functions were not part of C89 + appendices, they were introduced in C99. Therefore, the -D_XOPEN_SOURCE=500 option should better be added to the detection of flags for C99, not C89. (But be careful to use it only for HP-UX! On other systems, this flag is very likely to cause damage.) OTOH, AC_PROG_CC (which is what nearly every packages uses) assumes the user wants C89, not C99. Hmm? Bruno