On Mon, Jul 02, 2018 at 11:58:54PM +1200, David Phillips wrote: > On Mon, Jul 02, 2018 at 01:20:42PM +0200, Quentin Rameau wrote: > > Ok, the makedev(3) manpage from the man-pages states this indeed: > > > > The BSDs expose the definitions for these macros via <sys/types.h>. > > Depending on the version, glibc also exposes definitions for these > > macros from that header file if suitable feature test macros are > > defined. However, this behavior was deprecated in glibc 2.25, and since > > glibc 2.28, <sys/types.h> no longer provides these definitions. > > > > musl still includes <sys/sysmacros.h> from <sys/types.h> so maybe we > > would only need an #ifdef __GLIBC__ thereā¦ > > > > Or a more complicated > > #ifdef __GLIBC__ > > #if __GLIBC_PREREQ(2, 25) > > #include <sys/sysmacro.h> > > #endif > > #else > > #include <sys/types.h> > > #endif > > To simplify things on our side, couldn't we just include > <sys/sysmacros.h> if linking against glibc, regardless of its > version? > > It sounds like glibc has defined these in <sys/sysmacros.h> > for a while into the past (citation needed) and all that > is going to change is the inclusion of this file from types.h > > I know it's less "correct", but it doesn't seem prone to > breakage if that assumption is correct. > > Might not be worth the slight increase in clarity though, not > really sure. > > Thanks, > David
Reworked patch encompassing this behaviour is attached. Would be interested to see builds against glibc pre-2.25. Let me know what you think. Thanks, David
>From 331a370ffd51876a98e81ef330f27631c4e46859 Mon Sep 17 00:00:00 2001 From: David Phillips <da...@sighup.nz> Date: Mon, 2 Jul 2018 19:42:41 +1200 Subject: [PATCH] [sbase] On glibc, include sysmacros.h directly On glibc, major, minor, and makedev are all defined in sys/sysmacros.h with types.h only including this for historical reasons. A future release of glibc will remove this behaviour, meaning that major, minor, and makedev will no longer be defined for us without including sysmacros.h. --- ls.c | 7 +++++++ tar.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/ls.c b/ls.c index b716aba..4c269bd 100644 --- a/ls.c +++ b/ls.c @@ -1,6 +1,13 @@ /* See LICENSE file for copyright and license details. */ #include <sys/stat.h> + +/* glibc 2.25+ deprecates bringing sysmacros.h in with types.h anymore + * to define major and minor */ +#ifdef __GLIBC__ +#include <sys/sysmacros.h> +#else #include <sys/types.h> +#endif #include <dirent.h> #include <grp.h> diff --git a/tar.c b/tar.c index a6ead2e..c4a7435 100644 --- a/tar.c +++ b/tar.c @@ -2,6 +2,14 @@ #include <sys/stat.h> #include <sys/time.h> +/* glibc 2.25+ deprecates bringing sysmacros.h in with types.h anymore + * to define major, minor, and makedev */ +#ifdef __GLIBC__ +#include <sys/sysmacros.h> +#else +#include <sys/types.h> +#endif + #include <errno.h> #include <fcntl.h> #include <grp.h> -- 2.17.1