On Sunday 21 April 2013, Mark Kettenis wrote: > > +++ b/sys/sys/types.h > > @@ -177,6 +177,11 @@ typedef __clockid_t clockid_t; > > > > typedef __size_t size_t; > > #endif > > > > +#ifndef _PTRDIFF_T_DEFINED_ > > +#define _PTRDIFF_T_DEFINED_ > > +typedef __ptrdiff_t ptrdiff_t; > > +#endif > > You can't put ptrdiff_t in <sys/types.h> either.
Why not? POSIX only speaks about "at least the following types" in sys/types.h, so there is no reason why it may not define more types. And the ifndef guard will prevent conflicts with stddef.h (which is the canonical place for ptrdiff_t according to C99). > I lost track a bit what you're trying to achieve here (been a tad > bit busy). But I don't think we'd want to use ptrdiff_t in the > kernel. The starting point was that the compiler produces ptrdiff_t when subtracting two pointers, and Theo preferred using the standard compliant %td format string for it over %ld (or %zd). And if we have a printf format string for ptrdiff_t, it makes sense to be able to cast to it. But it's not strictly necessary, of course.