bug-gnu-libiconv
[Top][All Lists]
Advanced

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

Re: [bug-gnu-libiconv] libiconv-1.13.1 fails to build on hppa*-hpux due


From: Bruno Haible
Subject: Re: [bug-gnu-libiconv] libiconv-1.13.1 fails to build on hppa*-hpux due to mbstate_t
Date: Mon, 22 Nov 2010 18:50:50 +0100
User-agent: KMail/1.9.9

Hi,

Peter O'Gorman wrote:
>         /bin/sh ../libtool --mode=compile cc -I. -I. -I../include
> -I./../include -I.. -I./..  -g  -DLIBDIR=\"/usr/local/lib\"
> -DBUILDING_LIBICONV -DBUILDING_DLL  -DENABLE_RELOCATABLE=1 -DIN_LIBRARY
> -DINSTALLDIR=\"/usr/local/lib\" -DNO_XMALLOC
> -Dset_relocation_prefix=libiconv_set_relocation_prefix
> -Drelocate=libiconv_relocate -DHAVE_CONFIG_H -c ./iconv.c
> libtool: compile:  cc -I. -I. -I../include -I./../include -I.. -I./.. -g
> -DLIBDIR=\"/usr/local/lib\" -DBUILDING_LIBICONV -DBUILDING_DLL
> -DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"/usr/local/lib\"
> -DNO_XMALLOC -Dset_relocation_prefix=libiconv_set_relocation_prefix
> -Drelocate=libiconv_relocate -DHAVE_CONFIG_H -c ./iconv.c  +Z -DPIC -o
> .libs/iconv.o
> cc: "../include/iconv.h", line 120: error 1000: Unexpected symbol:
> "mbstate_t".
> cc: "../include/iconv.h", line 120: error 1573: Type of "dummy2" is
> undefined due to an illegal declaration.
> 
> This is, of course, because _XOPEN_SOURCE is not defined to 500

For this reason, the installation instructions (libiconv/INSTALL.generic)
contain an explicit blurb about HP-UX:

  Particular Systems
  ==================

     On HP-UX, the default C compiler is not ANSI C compatible.  If GNU CC
  is not installed, it is recommended to use the following options in order
  to use an ANSI C compiler:

       ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"

  and if that doesn't work, install pre-built binaries of GCC for HP-UX.

> iconv.h is a public header, so every
> client of libiconv would have to ensure that _XOPEN_SOURCE is defined to
> 500 before including iconv.h, which could be problematic.
> 
> Putting the #define in iconv.h.in itself could also cause issues with
> clients having to ensure that wchar.h does not get #included before
> iconv.h.
> 
> Is there a better solution? 

Good point. I can see two hacks that would solve the problem:
  a) Don't define iconv_allocation_t and don't declare iconv_open_into
     on HP-UX.
  b) Replace
       mbstate_t dummy2;
     with
       long mbstate_t[N];
     where N = ceil (sizeof (mbstate_t) / sizeof (long)) has been computed
     at compile time.
But mbstate_t is such basic type, present in the standards for long enough
time, that I think it's just the best if everyone adds
"-Ae -D_XOPEN_SOURCE=500" to his compilation flags on this platform.

I mean, some other platforms have the requirement that you compile with
-D_POSIX_SOURCE.
And Autoconf's AC_PROG_CC or AC_HEADER_STDC sets this flag also. So the
only way to compile a GNU program without this flag is when you specify
CC and CFLAGS explicitly without this flag. In that case, you have to
blame yourself.

Bruno



reply via email to

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