--- CodingStyle 2002/06/12 21:18:52 1.1 +++ CodingStyle 2010/12/22 16:52:52 1.4 @@ -1,13 +1,9 @@ ----------------------------------------------------------------------- - XviD Core coding style - - Inspired by the Linux Kernel Coding Style - ----------------------------------------------------------------------- +CodingStyle +=========== This is a short document describing the preferred coding style for the -XviD core library. Coding style is very personal, and we won't +Xvid core library. Coding style is very personal, and we won't _force_ our views on anybody. But if everybody who submits patches/codes to the CVS respect this coding style, the whole source would be easier to read/understand for all the others developers. @@ -22,7 +18,7 @@ In short, 8-char indents would have made things easier to read, and would have the added benefit of warning you when you're nesting your -functions too deep. But because of some parts of the XviD code source +functions too deep. But because of some parts of the Xvid code source has to use lot of if/else/for statements together, we have chosen to set the standard tab length to 4 characters. @@ -54,11 +50,11 @@ int function(int x) { body of function - } + } struct foo_t { - body of the strcuture + body of the structure } Note that the closing brace is empty on a line of its own, _except_ in @@ -76,10 +72,9 @@ .. } else if (x > y) { ... - } - else { + } else { .... - } + } Chapter 3: Naming @@ -99,7 +94,7 @@ function that counts the number of active users, you should call that "count_active_users()" or similar, you should _not_ call it "cntusr()". Try not to use global variables as they break reentrancy -and XviD aims to be (in a long term) a threadable library. +and Xvid aims to be (in a long term) a threadable library. Encoding the type of a function into the name (so-called Hungarian @@ -145,7 +140,7 @@ and it gets confused. You know you're brilliant, but maybe you'd like to understand what you did 2 weeks from now. -NB : This chapter does not apply very well to some XviD parts, but +NB : This chapter does not apply very well to some Xvid parts, but keep this "philosphy" in mind anyway. @@ -180,7 +175,7 @@ file: (defun xvid-c-mode () - "C mode with adjusted defaults for use with the XviD Sources." + "C mode with adjusted defaults for use with the Xvid Sources." (interactive) (c-mode) (message "Loading xvid-c-mode") @@ -232,7 +227,7 @@ Chapter 8: Reentrance -Well, at the moment, XviD is not a reentrant library because during +Well, at the moment, Xvid is not a reentrant library because during its development, some mistakes have been comited. But reentrance is a long term aim for this project so you should not write code which is not reentrant. @@ -259,7 +254,7 @@ 64bit on 64 bit CPUs (ultra sparc, AMD hammer, Intel Itanium, Motorola powerpc64) -But don't forget that the minimum platform targeted by the XviD +But don't forget that the minimum platform targeted by the Xvid library is a 32bit cpu. So a 'int' should (never say 'is' in such a case) always be 32bit long (or bigger) @@ -268,7 +263,9 @@ The code _must_ be portable. Don't use specific functions to a compiler/OS/libC. Don't use specific compiler pragmas, or syntax -extensions. +extensions. The code _must_ be ANSI C compliant to ease portability +on exotic platforms with only ANSI C compilers, much more widespread +than ISO C99 compilers. Btw, if you have to use those deprecated/not portable features, then use the src/portab.h to write a wrapper for each targeted system. @@ -276,7 +273,10 @@ For the moment, the supported platforms are : - Win32 family (x86) with VC++ - Cygwin env (bypassing the cygwin.dll with -mno-cygwin flag) - - Mingw ??? + - Mingw + Minsys - GNU/Linux (x86 and ppc for optimized code, or any other arch for the pure C version of the library) - - *BSD (same archs as GNU/Linux) \ No newline at end of file + - *BSD (same archs as GNU/Linux) + - Solaris. + +Last edited: $Date: 2010/12/22 16:52:52 $