This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: remove <sys/sysmacros.h> from <sys/types.h>
- From: Rich Felker <dalias at libc dot org>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: Andreas Schwab <schwab at linux-m68k dot org>, Roland McGrath <roland at hack dot frob dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Sat, 14 Nov 2015 16:59:08 -0500
- Subject: Re: RFC: remove <sys/sysmacros.h> from <sys/types.h>
- Authentication-results: sourceware.org; auth=none
- References: <CAKCAbMiU=h2Vs3X-b8mRjP3Kig_TVngObPNpYauTqZs_=0q6Gg at mail dot gmail dot com> <20151113234333 dot D1DCA2C3B7B at topped-with-meat dot com> <m2ziyhszvk dot fsf at linux-m68k dot org> <CAKCAbMhnz=PSQZ=yxVbrBpmL8sw5XznBz88HPiwSQD4kbcRXmQ at mail dot gmail dot com>
On Sat, Nov 14, 2015 at 03:41:08PM -0500, Zack Weinberg wrote:
> On Sat, Nov 14, 2015 at 4:18 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> > Roland McGrath <roland@hack.frob.com> writes:
> >
> >> What do the modern BSDs do about this issue?
> >
> > Nothing, they have the same problem.
> >
> > https://svnweb.freebsd.org/base/head/sys/sys/types.h?view=markup#l356
> >
> > (__BSD_VISIBLE is the equivalent of __USE_BSD.)
>
> However, if I'm reading these headers correctly, FreeBSD does *not*
> include sys/types.h in stdlib.h. (It does include sys/_types.h but I
Exactly. While I would like to get rid of _all_ implicit inclusion of
sys/sysmacros.h, I think it's the _interaction_ of these two implicit
inclusions (stdlib->sys/types and sys/types->sys/sysmacros) that's
extremely problematic. Modern software has little if any reason to
include sys/types.h anyway, but basically everything has to include
stdlib.h, and having stdlib indirectly define major() and minor() is
almost as embarassing as MSVC's defining of min() and max(). One way
or another this really needs to be fixed.
One way to fix this would be to make stdlib.h include a new header,
sys/real_types.h or something (or the FreeBSD name, sys/_types.h), and
have sys/types.h just be:
#include <sys/real_types.h>
#if ...
#include <sys/sysmacros.h>
#endif
But again I would just prefer getting rid of all implicit inclusion of
sysmacros.h.
Rich