bug-cvs
[Top][All Lists]
Advanced

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

Re: stdint module on SGI


From: Mark D. Baushke
Subject: Re: stdint module on SGI
Date: Mon, 26 Jun 2006 10:31:20 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Bruno,

I believe your patch has a typo. It uses _c99 instead of __c99 as the
symbol that the SGI c99 compiler defines.

        -- Mark

Bruno Haible <address@hidden> writes:

> Mark D. Baushke wrote:
> > Yes. I am told that /usr/include/stdint.h has the following:
> > 
> > #ifndef __c99
> > #error This header file is to be used only for c99 mode compilations
> > #else
> > 
> > #endif
> > 
> > The #else clause contains the typedefs one normally assumes are in
> > <stdint.h>.
> > 
> > The <inttypes.h> file similarly does this:
> > 
> > #if !(defined(__c99))
> > /* ... all of the c89 typedefs go here */
> > #else
> > 
> > #include <stdint.h>
> > #include <wchar.h>
> > /* ... all of the rest of the c99 stuff for <inttypes.h> goes here */
> > #endif /* __c99 */
> > 
> > > !        - in c89 mode, <stdint.h> spews warnings and <inttypes.h> too
> > > !          defines all types and macros that are defined in <stdint.h>.
> > > !      So we rely only on <inttypes.h> (included above).  */
> > 
> > Yes, the #error in c89 mode is considered a warning under normal
> > circumstances.
> 
> 
> But unlike what Larry and explained in the other mails, there is
> an additional problem: In c89 mode, <inttypes.h> does not define all
> of the contents of <stdint.h>. It does not define int_least8_t,
> for example.

Yes, you are correct. We need to have the generated <stdint.h> create
the {,u}int_leastN_t types to be correct.

> What to do in this case? Use the <stdint.h> because it has more types
> defined, and tell people to ignore the warnings? Or not?

Those extra types are only available if a c99 compiler is in use and the
__c99 symbol is therefore defined. If the __c99 symbol is not defined, then
the only thing that the <stdint.h> file does is a '#error'.

> I'm trying to not include <stdint.h>, like you suggest. Because
>   - gnulib's <stdint.h> shadows the system's one. In other words, it's
>     hard to come into a situation where the system's <stdint.h> will
>     be used.

If the user is using the c99 compiler, then there is probably no need to
use the GNULIB version at all.

>   - Anyone using the system's <stdint.h> is likely to stop doing so,
>     because of the #error warnings.

Yes.

> > I suppose an alternative would be
> > 
> > #if @HAVE_STDINT_H@
> > # if (!defined(__sgi) || defined(__c99)) && @HAVE_INTTYPES_H@
> > #  include @FULL_PATH_STDINT_H
> > # endif
> > #endif
> 
> The "&& @HAVE_INTTYPES_H@" puts in the assumption that all systems
> that have an <stdint.h> also have an <inttypes.h>. Quite possible.
> But the less assumptions we need to make, the better.

True enough. I like you patch other than the typo in the __c99 name.

I also wonder if you will consider doing something about the missing
WCHAR_MIN macro in your <stdint.h> replacement such as this:

#if !defined(WCHAR_MIN) && defined(HAVE_WCHAR_H)
# include <wchar.h>
#endif

for when <stddef.h> is not defining it.

        -- Mark

> 
> Bruno
> 
> 
> *** lib/stdint_.h     26 Jun 2006 13:06:51 -0000      1.20
> --- lib/stdint_.h     26 Jun 2006 16:52:56 -0000
> ***************
> *** 67,73 ****
>   #endif
>   #if @HAVE_STDINT_H@
>     /* Other systems may have an incomplete <stdint.h>.  */
> ! # include @FULL_PATH_STDINT_H@
>   #endif
>   
>   /* 7.18.1.1. Exact-width integer types */
> --- 67,82 ----
>   #endif
>   #if @HAVE_STDINT_H@
>     /* Other systems may have an incomplete <stdint.h>.  */
> !   /* On some versions of IRIX, the SGI C compiler comes with an <stdint.h>,
> !      but
> !        - in c99 mode, <inttypes.h> includes <stdint.h>,
> !        - in c89 mode, <stdint.h> spews warnings. <inttypes.h> defines only
> !          a subset of the types and macros that are defined in <stdint.h>.
> !      So we rely only on <inttypes.h> (included above).  It means that in
> !      c89 mode, we shadow the contents of warning-spewing <stdint.h>.  */
> ! # if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(_c99))
> ! #  include @FULL_PATH_STDINT_H@
> ! # endif
>   #endif
>   
>   /* 7.18.1.1. Exact-width integer types */
> *** m4/stdint.m4      26 Jun 2006 13:06:51 -0000      1.9
> --- m4/stdint.m4      26 Jun 2006 16:52:56 -0000
> ***************
> *** 1,4 ****
> ! # stdint.m4 serial 9
>   dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
>   dnl This file is free software; the Free Software Foundation
>   dnl gives unlimited permission to copy and/or distribute it,
> --- 1,4 ----
> ! # stdint.m4 serial 10
>   dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
>   dnl This file is free software; the Free Software Foundation
>   dnl gives unlimited permission to copy and/or distribute it,
> ***************
> *** 105,111 ****
>   #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
>   # include FULL_PATH_INTTYPES_H
>   #endif
> ! #if HAVE_STDINT_H
>   # include FULL_PATH_STDINT_H
>   #endif
>   '
> --- 105,111 ----
>   #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
>   # include FULL_PATH_INTTYPES_H
>   #endif
> ! #if HAVE_STDINT_H && !(defined(__sgi) && HAVE_INTTYPES_H && !defined(_c99))
>   # include FULL_PATH_STDINT_H
>   #endif
>   '
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (FreeBSD)

iD8DBQFEoBnoCg7APGsDnFERAqzsAKDTqLx92VEx2R4ee1fsdRxbZYbukgCgh/D0
BJ8o3h3z135JBZRzZV/fTEg=
=egqS
-----END PGP SIGNATURE-----




reply via email to

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