blob: 4b7f6d1bcd0fd277a6275802808acce97c31dde0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<!-- $NetBSD: functions.xml,v 1.2 2006/10/06 21:44:30 rillig Exp $ -->
<chapter id="functions">
<title>C/C++: functions</title>
<para>This chapter contains the requirements for using certain functions
in C and C++ code.</para>
<sect1 id="feature">
<title>Feature test macros</title>
<para>When writing code that conforms to a specific standard, some
programmers may want to check that really only features from that
standard are used. For that purpose there exist a number of so-called
feature test macros that can be defined on the command line to the
compiler or in C and C++ source files before including any of the
standard include files.</para>
<table>
<title>Documentation of the feature test macros</title>
<tgroup cols="2">
<thead>
<row><entry>Platform</entry><entry>Location</entry></row>
</thead>
<tbody>
<row><entry>SunOS-*-*</entry><entry><literal>standards(5)</literal></entry></row>
<row><entry>NetBSD-*-*</entry><entry><filename>/usr/include/sys/featuretest.h</filename></entry></row>
<row><entry>Linux-*-*</entry><entry><filename>/usr/include/features.h</filename></entry></row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 id="functions.byname">
<title>Functions on various platforms</title>
<sect2 id="functions.getopt">
<title>getopt</title>
<para>Solaris provides the <function>getopt</function> function in three
of the standard headers: <stdio.h>, <stdlib.h> and
<unistd.h>, but the latter definition depends on other feature
test macros than the first two. Additionally, since Solaris 5.10, there
is also <getopt.h>, which provides
<function>getopt_long</function>, but not <function>getopt</function>.
The exact behavior also depends on the compiler. While SUNpro is quite
strict and requires the feature test macros, gcc finds the definition
without any of these macros. (TODO: Investigate further.)</para>
<informaltable>
<tgroup cols="4">
<thead><row>
<entry>Platform</entry>
<entry>Library</entry>
<entry>Headers</entry>
<entry>Feature test macros</entry>
</row></thead>
<tbody>
<row>
<entry>NetBSD-*-*</entry>
<entry>c</entry>
<entry>unistd.h</entry>
<entry>_POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE >= 4 || defined(_NETBSD_SOURCE)</entry>
</row>
<row>
<entry>SunOS-5.10-*</entry>
<entry>c</entry>
<entry>unistd.h</entry>
<entry>(_XOPEN_SOURCE && _XOPEN_VERSION == 4) || __EXTENSIONS__</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
</sect1>
</chapter>
|