Created attachment 7377 0001-Add-sys-sysmacros.h-include-required-for-glibc-2.25.patch When building against glibc-2.25+: devperf.c: In function ‘DevGetPerfData1’: devperf.c:65:32: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration] const int iMajorNo = major(p_iDevice), ^ devperf.c:66:13: warning: implicit declaration of function ‘minor’ [-Wimplicit-function-declaration] iMinorNo = minor(p_iDevice); ^ devperf.c:69:21: error: ‘major’ redeclared as different kind of symbol unsigned int major, minor, rsect, wsect, ruse, wuse, use; ^ devperf.c:65:32: note: previous implicit declaration of ‘major’ was here const int iMajorNo = major(p_iDevice), ^ devperf.c:69:28: error: ‘minor’ redeclared as different kind of symbol unsigned int major, minor, rsect, wsect, ruse, wuse, use; ^ devperf.c:66:13: note: previous implicit declaration of ‘minor’ was here iMinorNo = minor(p_iDevice); ^ devperf.c:87:2: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] fscanf (pF, "%*s"); /* Skip device name */ ^ This version of glibc no longer implicitly includes major/minor macros via other headers. It requires using <sys/sysmacros.h> for that explicitly (it also works on BSD). I'm attaching a patch fixing the issue.
With glibc 2.26: devperf.c: In function ‘DevGetPerfData1’: devperf.c:65: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>. const int iMajorNo = major(p_iDevice), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I can confirm that the patch fix the problem
OpenBSD doesn't have sysmacros.h :)
I'd rather have this within a #ifdef _SOMETHING_GLIBC but the patch is fine otherwise
Only freebsd has one in its source tree (cf http://bxr.su/search?q=&defs=&refs=&path=sysmacros.h) and it's not even installed, so yeah only for GLIBC that is.
Created attachment 7382 0001-Support-sys-sysmacros.h-include-required-for-glibc-2.patch How about this one? It adds a configure check, so I guess it's the safest option.
Right, that's a valid option... but if we know that only glibc has this behaviour (what about musl libc ?) i'd have thought about #if defined(__GLIBC__), but i dont even know if that's the canonical way to detect glibc..
My point being if sysmacros.h is needed only for glibc > 2.25, it should be included only in this case :) otherwise it's context pollution... but that's not a huge deal.
So maybe #if defined(__GLIBC__) && __GLIBC__ > 2 && __GLIBC_MINOR__ > 25, if that works for you.. assuming that if __GLIBC__ is defined, then __GLIBC_MINOR__ is defined too.
I think Gentoo has been backporting this patch to older versions, so I'd rather not rely on specific versions. The autoconf variant is relatively safe, and should not require any further work once other libcs follow suit. After all, the rationale makes sense -- major() and minor() names are very collision-prone, so they should not be included along with commonly used stuff.
Oh, but you mean sys/sysmacros.h is a *new* header that appeared with this glib version ?
No, it was always there. Previously it was included implicitly, though.
Sorry i had completely forgotten this - your last patch is applied in 0787a89, thanks !