This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: GCC headers and DJGPP port


On Thu, Jul 20, 2000 at 10:27:09AM -0700, Bruce Korb wrote:
> Zack Weinberg wrote:
> > 
> > On Thu, Jul 20, 2000 at 08:25:40AM -0700, Bruce Korb wrote:
> > ...
> > > The amusing thing about that is that stddef.h is not platform
> > > specific, even though the SIZE_TYPE, PTRDIFF_TYPE and WCHAR_TYPE
> > > defines are.  I'm thinking that fixincludes should do its thing
> > > on the GCC-supplied stddef.h since fixincludes replaces these
> > > typedefs with platform-specific changes (as of today :-).
> > 
> > Our stddef.h uses the magic __SIZE_TYPE__, __PTRDIFF_TYPE__, and
> > __WCHAR_TYPE__ defines, which are set by cpp to the values of the
> > SIZE_TYPE, etc. defines in tm.h.  And fixincludes should too.
> 
> fixincludes did not ever do so, prior to today, that is.  :-)
> I grepped the CVS source for stddef.h and found absolutely no
> reference to "__PTRDIFF_TYPE__", except the three below.  Also,
> there was no reference to "PTRDIFF_TYPE" at all, period.

As I said, __SIZE_TYPE__ et al are magic defines, built into cpp.  You
must have missed this chunk of cppinit.c:

static const struct builtin builtin_array[] =
{
  /* ... */
#ifndef NO_BUILTIN_SIZE_TYPE
  C("__SIZE_TYPE__",            SIZE_TYPE),
#endif
#ifndef NO_BUILTIN_PTRDIFF_TYPE
  C("__PTRDIFF_TYPE__",         PTRDIFF_TYPE),
#endif
#ifndef NO_BUILTIN_WCHAR_TYPE
  C("__WCHAR_TYPE__",           WCHAR_TYPE),
#endif
};

SIZE_TYPE, WCHAR_TYPE, and PTRDIFF_TYPE come from tm.h.  If a port
defines one of the NO_BUILTIN_* macros, then it is required to set the
corresponding __*_TYPE__ macro in its specs.  This is done for
e.g. powerpc, where the correct values depend on -m switches.

I do not know why stddef.h has default definitions of these macros;
perhaps in case a non-GCC compiler ever used our stddef.h.

The vast majority of the complexity of stddef.h has to do with how it
interacts with system-provided headers.  Not on the actual definition
of size_t, etc. but on the interlock mechanism which prevents
duplicate typedefs.  And I don't think fixincludes is prepared to help
with that.  It would need a huge table recording the appropriate
interlock to use for each platform.

I might also add that some modern C libraries, such as glibc, know
exactly which headers are provided by gcc and do not have their own
copies.

zw

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