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