GNOME Bugzilla – Bug 776173
Missing sys/sysmacros.h #include, needed for experimental glibc versions
Last modified: 2017-02-14 18:33:06 UTC
Created attachment 342076 [details] Build log glibc is moving towards removing major() and minor() functions from the commonly used headers, and requiring explicit: #include <sys/sysmacros.h> for them. As a result, gparted does not build against Gentoo glibc-2.24 (not yet in ~arch): BlockSpecial.cc: In constructor ‘GParted::BlockSpecial::BlockSpecial(const Glib::ustring&)’: BlockSpecial.cc:64:31: error: ‘major’ was not declared in this scope m_major = major( sb.st_rdev ); ^ BlockSpecial.cc:65:31: error: ‘minor’ was not declared in this scope m_minor = minor( sb.st_rdev ); ^ I'm attaching the complete build log for 0.27.0 for completeness. I will attach a patch against git master soon.
Created attachment 342077 [details] [review] 0001-Include-sys-sysmacros.h-if-available-for-newer-glibc.patch Here's a patch that works for me. I've added a configure checks to cover for systems that do not have <sys/sysmacros.h>.
Created attachment 342159 [details] [review] Include sys/sysmacros.h (v2) Hi Michał, Thank you for the bug report and patch. Looking at Glibc and musl-libc histories I see that they both have always provided <sys/sysmacros.h> with definitions of major and minor macros. Therefore using an autoconf check and conditional inclusion seems unnecessary. I plan to use the attached patch in GParted which just unconditionally includes <sys/sysmacros.h>. I have successfully tested this patch on years old CentOS 5 with Glibc 2.5 and bang up to date Fedora Rawhide with Glibc 2.24.90. Please let me know if you see any problem with this. Thanks Mike By the way when I compile on Fedora Rawhide without this patch I just get the following warnings. Did that build of GParted on Gentoo have something set to remove Glibc deprecated definitions to make the build fail rather than report a warning? BlockSpecial.cc:64:13: warning: In the GNU C Library, "major" is defined by <sys/sysmacros.h>. For historical compatibility, it is currently defined by <sys/types.h> as well, but we plan to remove this soon. To use "major", include <sys/sysmacros.h> directly. If you did not intend to use a system-defined macro "major", you should undefine it after including <sys/types.h>. m_major = major( sb.st_rdev ); ^~~~~~~~~~~~~~~~~~~~ BlockSpecial.cc:65:13: warning: In the GNU C Library, "minor" is defined by <sys/sysmacros.h>. For historical compatibility, it is currently defined by <sys/types.h> as well, but we plan to remove this soon. To use "minor", include <sys/sysmacros.h> directly. If you did not intend to use a system-defined macro "minor", you should undefine it after including <sys/types.h>. m_minor = minor( sb.st_rdev ); ^~~~~~~~~~~~~~~~~~~~
(In reply to Mike Fleetwood from comment #2) > Looking at Glibc and musl-libc histories I see that they both have > always provided <sys/sysmacros.h> with definitions of major and minor > macros. Therefore using an autoconf check and conditional inclusion > seems unnecessary. I plan to use the attached patch in GParted which > just unconditionally includes <sys/sysmacros.h>. > > I have successfully tested this patch on years old CentOS 5 with > Glibc 2.5 and bang up to date Fedora Rawhide with Glibc 2.24.90. > > Please let me know if you see any problem with this. Well, that depends on which systems you aim to support. The conditional inclusion is better portability-wise. I know that at least Darwin doesn't (or didn't) have <sys/sysmacros.h> which caused issues for Mozilla's attempt to include it unconditionally [1]. [1]:http://hg.mozilla.org/mozilla-central/rev/f9aceff48e1b > By the way when I compile on Fedora Rawhide without this patch I just > get the following warnings. Did that build of GParted on Gentoo have > something set to remove Glibc deprecated definitions to make the build > fail rather than report a warning? It's actually using a custom patch to drop implicit sys/sysmacros.h include completely.
Hi Michał, I've pushed the following patch to GParted master for inclusion in the next release: Include sys/sysmacros.h for major and minor macros (#776173) https://git.gnome.org/browse/gparted/commit/?id=e4819fdd459d812f06ac30bfe577258d6fab7684 Mike
This enhancement was included in the GParted 0.28.0 release on February 14, 2017.