Project:Toolchain/Glibc 2.26 porting notes/sysmacros.h
From Gentoo Wiki
< Project:Toolchain(Redirected from Glibc 2.26 porting notes/sysmacros.h)
Jump to:navigation
Jump to:search
Description
To support upcoming c++
standards glibc
plans to remove <sys/sysmacros.h>
from glibc
's <sys/types.h>
. See the announcement.
<sys/sysmacros.h>
defines the following macros:
major()
minor()
makedev()
Build breakage usually looks like that:
bdev/lxclvm.c: In function 'lvm_detect': bdev/lxclvm.c:140:4: error: implicit declaration of function 'major' [-Werror=implicit-function-declaration] major(statbuf.st_rdev), minor(statbuf.st_rdev)); ^Grknight (talk) 14:53, 10 August 2021 (UTC) bdev/lxclvm.c:140:28: error: implicit declaration of function 'minor' [-Werror=implicit-function-declaration] major(statbuf.st_rdev), minor(statbuf.st_rdev)); ^Grknight (talk) 14:53, 10 August 2021 (UTC)
How to fix
autoconf-based systems
Note: <sys/sysmacros.h>
is a non-standard header.
Most portable fix across various libcs is to use [AC_HEADER_MAJOR] macro.
# somewhere in configure.ac: # lookup major()/minor()/makedev() AC_HEADER_MAJOR
/* somewhere in C code */
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
#endif
#ifdef MAJOR_IN_SYSMACROS
# include <sys/sysmacros.h>
#endif
Links
- Autoconf manual: AC_HEADER_MAJOR
- Tracking bug: bug #575232
- Example fix: https://github.com/lxc/lxc/commit/af6824fce9c9536fbcabef8d5547f6c486f55fdf