1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

Deprecate inclusion of <sys/sysmacros.h> by <sys/types.h>

The macros defined by <sys/sysmacros.h> 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.

	* NEWS: Inclusion of <sys/sysmacros.h> by <sys/types.h> is deprecated.
	* misc/sys/sysmacros.h: If __SYSMACROS_DEPRECATED_INCLUSION is defined,
	define major, minor, and makedev to issue deprecation warnings on use.
	If __SYSMACROS_DEPRECATED_INCLUSION is *not* defined, suppress
	previously-activated deprecation warnings for these macros and prevent
	subsequent inclusions of this header from having any effect.
	* posix/sys/types.h: Define __SYSMACROS_DEPRECATED_INCLUSION before
	including <sys/sysmacros.h>, and undefine it again afterward.
This commit is contained in:
Zack Weinberg
2016-05-10 11:07:42 -04:00
parent 63eb8df85a
commit dbab6577c6
4 changed files with 88 additions and 4 deletions

View File

@ -218,8 +218,14 @@ typedef int register_t __attribute__ ((__mode__ (__word__)));
/* It also defines `fd_set' and the FD_* macros for `select'. */
# include <sys/select.h>
/* BSD defines these symbols, so we follow. */
/* BSD defines `major', `minor', and `makedev' in this header.
However, these symbols are likely to collide with user code, so we are
going to stop defining them here in an upcoming release. Code that needs
these macros should include <sys/sysmacros.h> directly. Code that does
not need these macros should #undef them after including this header. */
# define __SYSMACROS_DEPRECATED_INCLUSION
# include <sys/sysmacros.h>
# undef __SYSMACROS_DEPRECATED_INCLUSION
#endif /* Use misc. */