]> git.saurik.com Git - apple/libc.git/blame - gen/compat.5
Libc-498.tar.gz
[apple/libc.git] / gen / compat.5
CommitLineData
224c7076 1.Dd October 23, 2005
3d9156a7
A
2.Os Darwin
3.Dt COMPAT 5
4.Sh NAME
5.Nm compat
6.Nd manipulate compatibility settings
7.Sh SYNOPSIS
8.Ev COMMAND_MODE=legacy|unix2003
9.Lp
10.Fd #define _POSIX_C_SOURCE
224c7076 11.Fd #define _DARWIN_C_SOURCE
3d9156a7 12.Fd #define _NONSTD_SOURCE
224c7076
A
13.Fd defined(__LP64__)
14.Lp
15.In sys/cdefs.h
16.Fd defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)
3d9156a7
A
17.Sh DESCRIPTION
18Setting the environment variable
19.Ev COMMAND_MODE
20to the value legacy causes utility programs to behave as closely to Mac OS X 10.3's utility programs as possible. When in this mode all of 10.3's flags are accepted, and in some cases extra flags are accepted, but no flags that were used in 10.3 will have been removed or changed in meaning. Any behavioral changes in this mode are documented in the LEGACY sections of the individual utilities.
21.Pp
22Setting the environment variable
23.Ev COMMAND_MODE
24to the value unix03 causes utility programs to obey the
25.St -susv3
26standards even if doing so would alter the behavior of flags used in 10.3.
27.Pp
224c7076
A
28The value of
29.Ev COMMAND_MODE
30is case insensitive and if it is unset or set to something other than legacy or unix03 it behaves as if it were set to unix03.
31.Sh 32-BIT COMPILATION
3d9156a7
A
32Defining
33.Dv _NONSTD_SOURCE
34causes library and kernel calls to behave as closely to Mac OS X 10.3's library and kernel calls as possible. Any behavioral changes in this mode are documented in the LEGACY sections of the individual function calls.
35.Pp
224c7076
A
36Defining
37.Dv _POSIX_C_SOURCE
3d9156a7 38or
224c7076
A
39.Dv _DARWIN_C_SOURCE
40causes library and kernel calls to conform to the SUSv3
41standards even if doing so would alter the behavior of functions used in 10.3.
42Defining
3d9156a7 43.Dv _POSIX_C_SOURCE
224c7076
A
44also removes functions, types, and other interfaces that are not part of SUSv3
45from the normal C namespace, unless
46.Dv _DARWIN_C_SOURCE
47is also defined (i.e.,
48.Dv _DARWIN_C_SOURCE
49is
50.Dv _POSIX_C_SOURCE
51with non-POSIX extensions).
52In any of these cases, the
53.Dv _DARWIN_FEATURE_UNIX_CONFORMANCE
54feature macro will be defined to the SUS conformance level (it is undefined
55otherwise).
3d9156a7 56.Pp
224c7076
A
57Starting in Mac OS X 10.5, if none of the macros
58.Dv _NONSTD_SOURCE ,
59.Dv _POSIX_C_SOURCE
60or
61.Dv _DARWIN_C_SOURCE
62are defined, and the environment variable
63.Ev MACOSX_DEPLOYMENT_TARGET
64is either undefined or set to 10.5 or greater (or equivalently, the
65.Xr gcc 1
66option
67.Fl mmacosx-version-min
68is either not specified or set to 10.5 or greater), then UNIX conformance will
69be on by default, and non-POSIX extensions will also be available
70(this is the equivalent of defining
71.Dv _DARWIN_C_SOURCE ) .
72For version values less that 10.5, UNIX conformance will be off (the
73equivalent of defining
74.Dv _NONSTD_SOURCE ) .
75.Sh 64-BIT COMPILATION
76When compiling for 64-bit architectures, the
77.Dv __LP64__
78macro will be defined to 1, and UNIX conformance is always on (the
79.Dv _DARWIN_FEATURE_UNIX_CONFORMANCE
80macro will also be defined to the SUS conformance level).
81Defining
3d9156a7 82.Dv _NONSTD_SOURCE
224c7076 83will cause a compilation error.
3d9156a7
A
84.Sh STANDARDS
85With COMMAND_MODE set to unix2003 utility functions conform to
224c7076 86.St -susv3 .
3d9156a7
A
87.Pp
88With
224c7076
A
89.Dv _POSIX_C_SOURCE ,
90.Dv _DARWIN_C_SOURCE ,
3d9156a7 91or
224c7076 92.Dv __LP64__ ,
3d9156a7 93system and library calls conform to
224c7076 94.St -susv3 .
3d9156a7 95.Sh BUGS
224c7076
A
96Different parts of a program can be compiled with different compatibility
97settings.
98The resultant program will normally work as expected, for example a regex
99created by the SUSv3
3d9156a7
A
100.Fn regcomp 3
101can be passed to the legacy
102.Fn regfree 3
103with no unexpected results. Some cases are less clear cut, for example
224c7076 104what does the programmer intend when they use the SUSv3
3d9156a7
A
105.Fn regcomp 3
106to compile a regex, but the legacy
107.Fn regexec 3
108to execute it? Any interpretation will surprise someone.