aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2019-01-10 13:01:03 +1300
committerMichael Kerrisk <mtk.manpages@gmail.com>2019-01-10 13:01:03 +1300
commit1be4da28c54b62bd012495a3bdaa86ef0ea8dc13 (patch)
tree7c6454003aff99f192743dca2570944aa00da1a8
parentc3a4afcae04a87ffa0c704ded9d0ce76137f323d (diff)
downloadman-pages-1be4da28c54b62bd012495a3bdaa86ef0ea8dc13.tar.gz
feature_test_macros.7: Add more detail on why FTMs must be defined before including any header
Reported-by: Andreas Westfeld <andreas.westfeld@htw-dresden.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r--man7/feature_test_macros.717
1 files changed, 17 insertions, 0 deletions
diff --git a/man7/feature_test_macros.7 b/man7/feature_test_macros.7
index e8d575ac2f..87630f4b99 100644
--- a/man7/feature_test_macros.7
+++ b/man7/feature_test_macros.7
@@ -36,6 +36,23 @@ This can be done either in the compilation command
.RI ( "cc \-DMACRO=value" )
or by defining the macro within the source code before
including any headers.
+The requirement that the macro must be defined before including any
+header file exists because header files may freely include one another.
+Thus, for example, in the following lines, defining the
+.B _GNU_SOURCE
+macro may have no effect because the header
+.I <abc.h>
+itself includes
+.I <xyz.h>
+(POSIX explicitly allows this):
+.PP
+.in +4n
+.EX
+#include <abc.h>
+#define _GNU_SOURCE
+#include <xys.h>
+.EE
+.in
.PP
Some feature test macros are useful for creating portable applications,
by preventing nonstandard definitions from being exposed.