Skip to content

Commit

Permalink
Inclusion of sysmacros.h by types.h is deprecated. (#2907)
Browse files Browse the repository at this point in the history
Inclusion of sysmacros.h by types.h is deprecated.

Release notes for glibc-2.25 state:

The inclusion of <sys/sysmacros.h> by <sys/types.h> is deprecated.
This means that in a future release, the macros “major”, “minor”, and
“makedev” will only be available from <sys/sysmacros.h>.

These macros are not part of POSIX nor XSI, and their names frequently
collide with user code; see for instance glibc bug 19239 and Red Hat
bug 130601. <stdlib.h> includes <sys/types.h> under _GNU_SOURCE, and
C++ code presently cannot avoid being compiled under _GNU_SOURCE,
exacerbating the problem.

evalfunction.c: In function ‘FnCallFileStatDetails’:
evalfunction.c:3191:64: error: implicit declaration of function ‘minor’; did you mean ‘mknod’? [-Werror=implicit-function-declaration]
             snprintf(buffer, CF_MAXVARSIZE, "%jd", (uintmax_t) minor(statbuf.st_dev) );
                                                                ^~~~~
                                                                mknod
evalfunction.c:3199:64: error: implicit declaration of function ‘major’ [-Werror=implicit-function-declaration]
             snprintf(buffer, CF_MAXVARSIZE, "%jd", (uintmax_t) major(statbuf.st_dev) );

(cherry picked from commit f7d5832)
  • Loading branch information
ekigwana authored and jimis committed Sep 27, 2017
1 parent 054b6ce commit 331919e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ AC_CHECK_HEADERS(winsock2.h)
AC_CHECK_HEADERS(ws2tcpip.h)
AC_CHECK_HEADERS(zone.h)
AC_CHECK_HEADERS(sys/uio.h)
AC_CHECK_HEADERS_ONCE([sys/sysmacros.h]) dnl glibc deprecated inclusion in sys/type.h
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/mpctl.h) dnl For HP-UX $(sys.cpus) - Mantis #1069
AC_CHECK_HEADERS(shadow.h)
Expand Down
5 changes: 5 additions & 0 deletions libutils/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
/* POSIX but available in all platforms. */
#include <strings.h>
#include <limits.h>

#ifdef HAVE_SYS_SYSMACROS_H
# include <sys/sysmacros.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>

Expand Down

0 comments on commit 331919e

Please sign in to comment.