autoconf
[Top][All Lists]
Advanced

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

Linux, autoconf 2.52: inttypes.h incompatibility with iostream [#5060]


From: Keith Bostic
Subject: Linux, autoconf 2.52: inttypes.h incompatibility with iostream [#5060]
Date: Thu, 6 Dec 2001 09:59:23 -0500 (EST)

I'm using autoconf 2.52, on Linux with gcc 3.0.2, glibc 2.2.4.

Our software needs fixed-size types, for example, "int32_t".
So, we look for the types, and, if we don't find them, we build
our own:

        # Check the sizes we know about, and see if any of them match
        # what's needed.
        #
        # $1 substitution variable
        # $2 type name
        # $3 size of type in bytes
        AC_DEFUN(AM_SEARCH_USIZES, [
                case "$3" in
                "$ac_cv_sizeof_unsigned_int")
                        $1="typedef unsigned int $2;";;
                "$ac_cv_sizeof_unsigned_char")
                        $1="typedef unsigned char $2;";;
                "$ac_cv_sizeof_unsigned_short")
                        $1="typedef unsigned short $2;";;
                "$ac_cv_sizeof_unsigned_long")
                        $1="typedef unsigned long $2;";;
                *)
                        AC_MSG_ERROR([No unsigned $3-byte integral type]);;
                esac])


        # We need to know the sizes of various objects on this system.
        # We don't use the SIZEOF_XXX values created by autoconf.
        AC_CHECK_SIZEOF(char)
        AC_CHECK_SIZEOF(unsigned char)
        AC_CHECK_SIZEOF(short)
        AC_CHECK_SIZEOF(unsigned short)
        AC_CHECK_SIZEOF(int)
        AC_CHECK_SIZEOF(unsigned int)
        AC_CHECK_SIZEOF(long)
        AC_CHECK_SIZEOF(unsigned long)
        AC_CHECK_SIZEOF(size_t)
        AC_CHECK_SIZEOF(char *)

        AC_SUBST(u_int32_decl)
        AC_CHECK_TYPE(u_int32_t)
        if test "$ac_cv_type_u_int32_t" = no; then
                AM_SEARCH_USIZES(u_int32_decl, u_int32_t, 4)
        fi

The problem is the standard include files autoconf uses include
<inttypes.h>.

If you take this code:

        #include <iostream>
        #include <inttypes.h>

and compile it on Linux with g++ -O2 (at least with gcc 3.0.2, glibc
2.2.4, but probably more), then compilation fails like this:

/usr/include/inttypes.h: In function `intmax_t wcstoimax(const __gwchar_t*, 
   __gwchar_t**, int)':
/usr/include/inttypes.h:432: cannot convert `const __gwchar_t* __restrict' to 
   `const wchar_t*' for argument `1' to `long long int
__wcstoll_internal(const    wchar_t*, wchar_t**, int, int)'
/usr/include/inttypes.h: In function `uintmax_t wcstoumax(const __gwchar_t*, 
   __gwchar_t**, int)':
/usr/include/inttypes.h:451: cannot convert `const __gwchar_t* __restrict' to 
   `const wchar_t*' for argument `1' to `long long unsigned int 
   __wcstoull_internal(const wchar_t*, wchar_t**, int, int)'

What is going on is that compiling with optimization turns on inlining
via a preprocess macro __USE_EXTERN_INLINES, and the inlined code in
inttypes.h is incompatible with wchar.h, which is being included via
iostream.

Does anybody have any suggestions as to how to solve this problem?

My only idea at the moment is to change autoconf's default includes
to stop using inttypes.h at all, but that's pretty ugly.

Thank you!

--keith

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic
Sleepycat Software Inc.         address@hidden
118 Tower Rd.                   +1-781-259-3139
Lincoln, MA 01773               http://www.sleepycat.com



reply via email to

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