This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Use gnulib's stdint.h.

On Fri, Jun 27, 2008 at 02:59:07PM -0400, Joel Brobecker wrote:
> There are two distinct issues that I have seen so far:
>   1. dfp.c includes libdecnumber/dpd/decimal128.h which ends up
>      including gstdint.h. But before we included decimal128.h, we
>      had already included defs.h which includes gnulib/stdint.h.
>      The two files end up colliding.
>      For instance, gstdint.h contains:
>         typedef int16_t    int_least16_t;
>      But gnulib/stdint.h also contains:
>         #define int16_t short int
>         #define int_least16_t int16_t
>      So we end up with the above being rewritten to:
>         typedef short int short int;

Boo.  And if we change libdecnumber to use gnulib's version we'll
undoubtedly break gcc.  If we provide gstdint.h in the gdb directory
which redirects to <stdint.h>, will libdecnumber pick it up at this
point?  That relies on the types being in-practice compatible which
will be the case, rather than making the two headers compatible.

>   2. ctype/safe-ctype conflict. For instance, cp-support.c includes
>      safe-ctype.h.  But at the same time, we previously included
>      defs.h, which itself includes gnulib/stdint.h, which includes
>      <wchar.h> which includes <ctypes.h>.

> Problem #2 is a lot more problematic, however. I might argue that
> this is a actually bug inside gnulib and that gnulib/stdint.h
> should be generated in a way that avoids including other standard
> header files. Although this might be the case for the current
> stdint.h files that exist, I don't think there is an explicit
> rule against it. Even if not categorized as a bug, perhaps it
> would be a worthwhile enhancement, as the documented reason for
> including this file is to get a couple of macros:
>     #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
>     /* Get WCHAR_MIN, WCHAR_MAX.  */
>     # if ! (defined WCHAR_MIN && defined WCHAR_MAX)
>     #  include <wchar.h>
>     # endif
>     #endif
> Perhaps we could somehow generate the macro definitions ourselves,
> which would help avoiding the include. Ideally, gnulib would take
> care of that and avoid the include, or we could compute the WCHAR_MIN
> and WCHAR_MAX during the GDB configury and define the macros just
> before including gnulib/stdint.h.

I agree that having gnulib pull in wchar.h is very unfortunate.  The
gnulib folks, CC'd, are very responsive - maybe someone on bug-gnulib
has an idea on how to fix this?

Daniel Jacobowitz

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]