bug-gnulib
[Top][All Lists]
Advanced

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

Re: installable stdlib.h


From: Bruno Haible
Subject: Re: installable stdlib.h
Date: Sun, 13 Feb 2011 12:51:49 +0100
User-agent: KMail/1.9.9

Hi Paul,

> How about if we add an option to gnulib-tool
> to address this?  I.e., gnulib-tool could generate a stdin.in.h
> designed for the typical use of gnulib, or it could generate a
> stdin.in.h suitable for libunistring etc.  The typical use could
> employ Autoconf tests to accurately determine the current compiler's
> behavior; the private-copy use could work much as now, and generate
> less-accurate but still-acceptable results.

So far we've been handling both use cases pretty well together.
Introducing a gnulib-tool option for this would increase the testing
effort. Or, in other words, if we introduce such an option but don't
do more systematic testing in all possible configurations, bugs can
creep in that we don't notice.

There will soon be a gnulib-tool option --installable that tells gnulib-tool
to provide installable headers, but this is meant only to add snippets like

  pkginclude_nobase_HEADERS += stdlib.h

to the generated Makefile.am. (Needed for libposix.) But other than that, we
should try to minimize the difference between the two use cases.

But yes, when I look at the contortions libunistring is doing for
stdbool.h and stdint.h, it can be hard to satisfy all compilers at once:


# Produce an unistring/stdbool.h that is not compiler dependent.
# GCC >= 2.95 has <stdbool.h>.
# AIX >= 5.3 has <stdbool.h>.
# Solaris 10 and some HP-UX 11 versions have <stdbool.h> but it does not
# necessarily work.
unistring/stdbool.h : $(STDBOOL_H) stdbool.mini.h
        @MKDIR_P@ unistring
        rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          echo '#if !defined _GL_STDBOOL_H'; \
          if test -f /usr/include/stdbool.h; then \
            echo '#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) 
|| defined _AIX'; \
          else \
            echo '#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 
95))'; \
          fi; \
          echo '#include <stdbool.h>'; \
          echo '#else'; \
          cat $(srcdir)/stdbool.mini.h; \
          echo '#endif'; \
          echo '#endif'; \
        } > address@hidden
        mv address@hidden $@


# Produce an unistring/stdint.h that is not compiler dependent.
# Glibc >= 2 has <stdint.h>.
# On most other platforms that have it, it is buggy in one way or the other.
unistring/stdint.h : $(STDINT_H) stdint.mini.h
        @MKDIR_P@ unistring
        rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          echo '#include <stddef.h>'; \
          echo '#if __GLIBC__ >= 2'; \
          echo '#include <stdint.h>'; \
          echo '#else'; \
          if test -f /usr/include/stdint.h; then \
            HAVE_STDINT_H='1'; \
          else \
            HAVE_STDINT_H='defined __MINGW32__ || defined __HAIKU__'; \
          fi; \
          if test -f /usr/include/inttypes.h; then \
            HAVE_INTTYPES_H='1'; \
          else \
            HAVE_INTTYPES_H='defined __MINGW32__ || defined __HAIKU__'; \
          fi; \
          if test -f /usr/include/sys/inttypes.h; then \
            HAVE_SYS_INTTYPES_H='1'; \
          else \
            HAVE_SYS_INTTYPES_H='0'; \
          fi; \
          sed -e 's/@''HAVE_STDINT_H''@/'"$$HAVE_STDINT_H"'/g' \
              -e 's|@''INCLUDE_NEXT''@|include|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@||g' \
              -e 's|@''NEXT_STDINT_H''@|<stdint.h>|g' \
              -e 's/@''HAVE_SYS_TYPES_H''@/1/g' \
              -e 's/@''HAVE_INTTYPES_H''@/'"$$HAVE_INTTYPES_H"'/g' \
              -e 's/@''HAVE_SYS_INTTYPES_H''@/'"$$HAVE_SYS_INTTYPES_H"'/g' \
              -e 's/@''HAVE_SYS_BITYPES_H''@/0/g' \
              < $(srcdir)/stdint.mini.h; \
          echo '#endif'; \
        } > address@hidden
        mv address@hidden $@

Bruno
-- 
In memoriam Alexander Samoylovich 
<http://en.wikipedia.org/wiki/Alexander_Samoylovich>



reply via email to

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