GNOME Bugzilla – Bug 794651
Posix.major()/minor() are missing #include <sys/sysmacros.h>
Last modified: 2018-03-24 20:59:15 UTC
Created attachment 370082 [details] reproducer With glibc 2.26, the attached test program that exercises Posix.major() and minor() builds with a warning, but still works: $ valac --pkg posix -o /tmp/out major.vala /home/martin/src/test/vala/major.vala.c: In Funktion »_vala_main«: /home/martin/src/test/vala/major.vala.c:43:13: Warnung: 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>. _tmp6_ = major (_tmp5_); ^~~~~~~~~~~~~ /home/martin/src/test/vala/major.vala.c:46:13: Warnung: 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>. _tmp9_ = minor (_tmp8_); ^~~~~~~~~~~~~ But with glibc 2.27 (as in Fedora Rawhide) it does not work any more, as sys/types.h is now not sufficient any more: $ valac --pkg posix -o /tmp/out major.vala /home/martin/src/test/vala/major.vala.c: In function ‘_vala_main’: /home/martin/src/test/vala/major.vala.c:48:45: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration] fprintf (_tmp3_, "major: %u, minor: %u\n", major (_tmp5_), minor (_tmp7_)); ^~~~~ /home/martin/src/test/vala/major.vala.c:48:61: warning: implicit declaration of function ‘minor’; did you mean ‘mknod’? [-Wimplicit-function-declaration] fprintf (_tmp3_, "major: %u, minor: %u\n", major (_tmp5_), minor (_tmp7_)); ^~~~~ mknod /tmp/ccZtOWCJ.o: In function `_vala_main': major.vala.c:(.text+0x37a): undefined reference to `minor' major.vala.c:(.text+0x38d): undefined reference to `major' collect2: error: ld returned 1 exit status
Created attachment 370083 [details] [review] posix: Include sys/sysmacros.h for major(), minor() and makedev() Relying on sys/types.h is fatal since glibc 2.27 and was deprecated since glibc 2.25.
Works with glibc 2.23 on Ubuntu 16.04 and eglibc 2.19 on Ubuntu 14.04, so this should be good to go, even for backporting.
Attachment 370083 [details] pushed as 0277ea7 - posix: Include sys/sysmacros.h for major(), minor() and makedev()
Thanks Rico!