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