diff --git a/man7/feature_test_macros.7 b/man7/feature_test_macros.7 index ecae0c2fe..187f51105 100644 --- a/man7/feature_test_macros.7 +++ b/man7/feature_test_macros.7 @@ -112,12 +112,23 @@ feature test macro requirements (this example from .fi .RE .PP -This syntax is used in cases where only a single +This format is employed in cases where only a single feature test macro can be used to expose the function declaration, and that macro is not defined by default. .SS Feature test macros understood by glibc Linux/glibc understands the following feature test macros: .\" FIXME ? add _ATFILE_SOURCE to this list +.TP +.B __STRICT_ANSI__ +ISO Standard C. +This macro is implicitly defined by +.BR gcc (1) +when invoked with, for example, the +.I -std=c99 +or +.I -ansi +flag. + .TP .B _POSIX_C_SOURCE Defining this macro with the value 1 causes header files to expose @@ -139,24 +150,12 @@ with the value 1. .B _XOPEN_SOURCE Defining this macro with any value causes header files to expose definitions conforming to POSIX.1, POSIX.2, and XPG4. -Defining with the value 500 or greater additionally exposes +Defining this macro with the value 500 or greater additionally exposes definitions for SUSv2 (UNIX 98). -Defining with the value 600 or greater additionally exposes +Since glibc 2.2, defining this macro with the value 600 +or greater additionally exposes definitions for SUSv3 (UNIX 03; i.e., the POSIX.1-2001 base specification plus the XSI extension) and C 99 definitions. -.IP -Defining -.B _XOPEN_SOURCE -also implicitly defines -.BR _POSIX_C_SOURCE : -with the value 2, if -.B _XOPEN_SOURCE -is less than 500; -with the value 199506L, if 500 <= -.B _XOPEN_SOURCE -< 600; or with the value 200112L if -.B _XOPEN_SOURCE ->= 600. .TP .B _XOPEN_SOURCE_EXTENDED If this macro is defined with the value 1, and the @@ -221,16 +220,25 @@ System V-derived definitions. (SVID == System V Interface Definition; see .BR standards (7).) .TP +.B _ATFILE_SOURCE +Defining this macro with any value cause header files to expose +declarations of a range of functions with the suffix "at"; +see +.BR openat (2). +.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 +.BR _ISOC99_SOURCE , +.BR _XOPEN_SOURCE_EXTENDED , +.BR _POSIX_SOURCE , .BR _POSIX_C_SOURCE -with the value 200112L, and +with the value 200112L (199506L in glibc versions before 2.5), and .BR _XOPEN_SOURCE -with the value 600. +with the value 600 (500 in glibc versions before 2.2). In addition, various GNU-specific extensions are also exposed. Where standards conflict, BSD definitions are disfavored. .TP @@ -290,24 +298,70 @@ and result in a run-time error if the check fails. Use of this macro requires compiler support, available with .BR gcc (1) since version 4.0. -.SS Feature test macros defined by default +.SS Default definitions, implicit definitions, and combining definitions .PP -The following macros are defined by default: +The following feature test macros are defined by default: .BR _BSD_SOURCE , .BR _SVID_SOURCE , .BR _POSIX_SOURCE , and -.BR _POSIX_C_SOURCE =199506L. -If individual macros are defined, then other macros are disabled -unless they are also explicitly defined. -(Exception: if +.BR _POSIX_C_SOURCE =200112L +(199506L in glibc versions before 2.5). +.PP +If any of +.BR __STRICT_ANSI__ , +.BR _ISOC99_SOURCE , +.BR _POSIX_SOURCE , +.BR _POSIX_C_SOURCE , +.BR _XOPEN_SOURCE , +.BR _XOPEN_SOURCE_EXTENDED , +.BR _BSD_SOURCE , +or +.BR _SVID_SOURCE +is explicitly defined, then +.BR _BSD_SOURCE , +and +.BR _SVID_SOURCE +are not defined by default. + +If +.BR _POSIX_SOURCE +and .BR _POSIX_C_SOURCE -is not otherwise defined, -then it is always defined with the value 200112L -(199506L in glibc versions before 2.4), -unless the compiler is invoked in one of its standard modes, for example, the -.I -std=c99 -flag.) +are not explicitly defined, +and either +.BR __STRICT_ANSI__ +is not defined or +.BR _XOPEN_SOURCE +is defined with a value of 500 or more, then +.RS 6 +.IP * 3 +.B _POSIX_SOURCE +is defined with the value 1; and +.IP * +.B _POSIX_C_SOURCE +is defined with one of the following values: +.RS 6 +.IP \(bu 3 +2, +if +.BR XOPEN_SOURCE +is defined with a value less than 500; +.IP \(bu +199506L, +if +.BR XOPEN_SOURCE +is defined with a value greater than or equal to 500 and less than 600; +or +.IP \(bu +200112L (199506L in glibc versions before 2.5), +if +.BR XOPEN_SOURCE +is undefined, or +is defined with a value greater than or equal to 600. +.RE +.RE +.PP Multiple macros can be defined; the results are additive. .SH CONFORMING TO POSIX.1 specifies @@ -317,9 +371,11 @@ and .BR _XOPEN_SOURCE . .BR _XOPEN_SOURCE_EXTENDED was specified by XPG4v2 (aka SUSv1). + .BR _FILE_OFFSET_BITS is not specified by any standard, but is employed on some other implementations. + .BR _BSD_SOURCE , .BR _SVID_SOURCE , .BR _GNU_SOURCE ,