Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / doc / c-extensions
CommitLineData
7217e0ca
ML
1First of all: C89 or better. If you don't have that, port gcc first.
2
3Use of C language extensions throughout the X server tree
4---------------------------------------------------------
5
6Optional extensions:
7The server will still build if your toolchain does not support these
8extensions, although the results may not be optimal.
9
10 * _X_SENTINEL(x): member x of the passed structure must be NULL, e.g.:
11 void parseOptions(Option *options _X_SENTINEL(0));
12 parseOptions("foo", "bar", NULL); /* this is OK */
13 parseOptions("foo", "bar", "baz"); /* this is not */
14 This definition comes from Xfuncproto.h in the core
15 protocol headers.
16 * _X_ATTRIBUTE_PRINTF(x, y): This function has printf-like semantics;
17 check the format string when built with
18 -Wformat (gcc) or similar.
19 * _X_EXPORT: this function should appear in symbol tables.
20 * _X_HIDDEN: this function should not appear in the _dynamic_ symbol
21 table.
22 * _X_INTERNAL: like _X_HIDDEN, but attempt to ensure that this function
23 is never called from another module.
24 * _X_INLINE: inline this functon if possible (generally obeyed unless
25 disabling optimisations).
26 * _X_DEPRECATED: warn on use of this function.
27
28Mandatory extensions:
29The server will not build if your toolchain does not support these extensions.
30
31 * named initialisers: explicitly initialising structure members, e.g.:
32 struct foo bar = { .baz = quux, .brian = "dog" };
33 * variadic macros: macros with a variable number of arguments, e.g.:
34 #define DebugF(x, ...) /**/
35 * interleaved code and declarations: { foo = TRUE; int bar; do_stuff(); }
36
37
38Use of library facilities throughout the X server tree
39-------------------------------------------------------------
40
41Non-OS-dependent code can assume facilities at least as good as
42the non-OS-facility parts of POSIX-1.2001. Ideally this would
43be C99, but even gcc+glibc doesn't implement that yet.
44
45Unix-like systems are assumed to be at least as good as UNIX03.
46
47Note that there are two Windows ports, Cygwin and MinGW:
48- Cygwin is more or less like Linux.
49- MinGW is more restrictive. Windows does not provide the required
50POSIX facilities, so some non-OS-dependent code is stubbed out or
51has an alternate implementation if WIN32 is defined. Code that
52needs to be portable to Windows should be careful to, well, be portable.
53
54
55Required OS facilities
56-------------------------------------------------------------
57
58Linux systems must be at least 2.4 or later. As a practical matter
59though, 2.4 kernels never receive any testing. Use 2.6 already.
60
61TODO: Solaris.
62
63TODO: *BSD.
64
65Windows-dependent code assumes at least NT 5.1.
66
67OSX support is generally limited to the most recent version. Currently
68that means 10.5.