Skip to content
  • Michał Górny's avatar
    Include sys/sysmacros.h for major and minor macros (#776173) · e4819fdd
    Michał Górny authored and Mike Fleetwood's avatar Mike Fleetwood committed
    Glibc 2.25 is deprecating <sys/types.h> including <sys/sysmacros.h>.
        https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=dbab6577c6684c62bd2521c1c29dc25c3cac966f
        Deprecate inclusion of <sys/sysmacros.h> by <sys/types.h>
    
    Building on Fedora Rawhide with Glibc 2.24.90 produces these warnings:
    
        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 );
                     ^~~~~~~~~~~~~~~~~~~~
    
    Code needing major and minor macros should include <sys/sysmacros.h>
    directly.  As both Glibc and musl-libc have always provided this header
    and GParted is a Linux only application, just always include the header
    and don't bother with an autoconf check for its existence.
    
    Bug 776173 - Missing sys/sysmacros.h #include, needed for experimental
                 glibc versions
    e4819fdd