mirror of https://github.com/mkerrisk/man-pages
feature_test_macros.7: Improve discussion of _DEFAULT_SOURCE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
496bdb5642
commit
dfb1232ca8
|
@ -22,7 +22,7 @@
|
|||
.\" the source, must acknowledge the copyright and authors of this work.
|
||||
.\" %%%LICENSE_END
|
||||
.\"
|
||||
.TH FEATURE_TEST_MACROS 7 2014-01-06 "Linux" "Linux Programmer's Manual"
|
||||
.TH FEATURE_TEST_MACROS 7 2014-03-10 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
feature_test_macros \- feature test macros
|
||||
.SH SYNOPSIS
|
||||
|
@ -282,17 +282,24 @@ System V-derived definitions.
|
|||
.BR standards (7).)
|
||||
.TP
|
||||
.BR _DEFAULT_SOURCE " (since glibc 2.19)"
|
||||
Defining this macro provides an effect similar to
|
||||
the feature test macros that are defined by default; that is:
|
||||
|
||||
cc \-D_BSD_SOURCE \-D_SVID_SOURCE \-D_POSIX_C_SOURCE=200809
|
||||
|
||||
This macro can be defined to ensure that the "default"
|
||||
definitions are provided even when the defaults would otherwise
|
||||
be disabled,
|
||||
as happens when individual macros are explicitly defined,
|
||||
or the compiler is invoked in one of its "standard" modes (e.g.,
|
||||
.IR "cc\ \-std=c99" ).
|
||||
Defining
|
||||
.B _DEFAULT_SOURCE
|
||||
without defining other individual macros
|
||||
or invoking the compiler in one of its "standard" modes has no effect.
|
||||
|
||||
The "default" definitions comprise those required by POSIX.1-2008
|
||||
as well as various definitions derived from BSD and System V.
|
||||
On glibc 2.19 and earlier, these defaults were approximately equivalent
|
||||
to explicitly defining the following:
|
||||
|
||||
cc \-D_BSD_SOURCE \-D_SVID_SOURCE \-D_POSIX_C_SOURCE=200809
|
||||
|
||||
.TP
|
||||
.BR _ATFILE_SOURCE " (since glibc 2.4)"
|
||||
Defining this macro with any value causes header files to expose
|
||||
|
@ -305,8 +312,6 @@ is defined with a value greater than or equal to 200809L.
|
|||
.TP
|
||||
.B _GNU_SOURCE
|
||||
Defining this macro (with any value) is equivalent to defining
|
||||
.BR _BSD_SOURCE ,
|
||||
.BR _SVID_SOURCE ,
|
||||
.BR _ATFILE_SOURCE ,
|
||||
.BR _LARGEFILE64_SOURCE ,
|
||||
.BR _ISOC99_SOURCE ,
|
||||
|
@ -323,7 +328,17 @@ with the value 700
|
|||
(600 in glibc versions before 2.10;
|
||||
500 in glibc versions before 2.2).
|
||||
In addition, various GNU-specific extensions are also exposed.
|
||||
Where standards conflict, BSD definitions are disfavored.
|
||||
|
||||
Since glibc 2.19, defining
|
||||
.BR _GNU_SOURCE
|
||||
also has the effect of defining
|
||||
.BR _DEFAULT_SOURCE .
|
||||
In glibc versions before 2.20, defining
|
||||
.BR _GNU_SOURCE
|
||||
also had the effect of defining
|
||||
.BR _BSD_SOURCE
|
||||
and
|
||||
.BR _SVID_SOURCE .
|
||||
.TP
|
||||
.B _REENTRANT
|
||||
Defining this macro exposes definitions of certain reentrant functions.
|
||||
|
@ -387,6 +402,8 @@ If no feature test macros are explicitly defined,
|
|||
then the following feature test macros are defined by default:
|
||||
.BR _BSD_SOURCE ,
|
||||
.BR _SVID_SOURCE ,
|
||||
.BR _DEFAULT_SOURCE
|
||||
(since glibc 2.19),
|
||||
.BR _POSIX_SOURCE ,
|
||||
and
|
||||
.BR _POSIX_C_SOURCE =200809L
|
||||
|
@ -405,9 +422,10 @@ If any of
|
|||
or
|
||||
.B _SVID_SOURCE
|
||||
is explicitly defined, then
|
||||
.BR _BSD_SOURCE
|
||||
.BR _BSD_SOURCE ,
|
||||
.BR _SVID_SOURCE ,
|
||||
and
|
||||
.B _SVID_SOURCE
|
||||
.BR _DEFAULT_SOURCE
|
||||
are not defined by default.
|
||||
|
||||
If
|
||||
|
@ -483,6 +501,7 @@ but is employed on some other implementations.
|
|||
|
||||
.BR _BSD_SOURCE ,
|
||||
.BR _SVID_SOURCE ,
|
||||
.BR _DEFAULT_SOURCE ,
|
||||
.BR _ATFILE_SOURCE ,
|
||||
.BR _GNU_SOURCE ,
|
||||
.BR _FORTIFY_SOURCE ,
|
||||
|
@ -596,6 +615,10 @@ main(int argc, char *argv[])
|
|||
printf("_SVID_SOURCE defined\\n");
|
||||
#endif
|
||||
|
||||
#ifdef _DEFAULT_SOURCE
|
||||
printf("_DEFAULT_SOURCE defined\\n");
|
||||
#endif
|
||||
|
||||
#ifdef _ATFILE_SOURCE
|
||||
printf("_ATFILE_SOURCE defined\\n");
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue