CodingStyle.txt
branchstable-1.5
changeset 2125 af3eda069078
child 2127 0814802f5928
equal deleted inserted replaced
2124:c4afc5fede19 2125:af3eda069078
       
     1 $Id$
       
     2 
       
     3 vim: spelllang=en tw=78
       
     4 
       
     5 This is a short introduction to the coding style that shall be used. The below
       
     6 rules are applicable for all C source files, except the Ethernet drivers, for
       
     7 which the Linux Kernel coding style shall be used to minimize the
       
     8 differences).
       
     9 
       
    10 * Lines shall not exceed 78 characters.
       
    11 
       
    12 * Indentation shall be done using 4 space characters
       
    13 
       
    14 * No whitespace shall be left at the end of a line.
       
    15 
       
    16 * After a comma, a single space shall be placed (if not followed by a
       
    17   line break).
       
    18 
       
    19 * Braces shall be placed in the following way (K&R style):
       
    20 
       
    21     if (...) {
       
    22         ...
       
    23     } else if (...) {
       
    24         ...
       
    25     } else {
       
    26         ...
       
    27     }
       
    28 
       
    29     int function(...)
       
    30     {
       
    31         ...
       
    32     }
       
    33 
       
    34 * Macros shall be named in CAPITAL letters. If a macro contains multiple
       
    35   statements, they should be enclosed by a 'do {} while (0)' loop. Macro
       
    36   parameters shall also be capital letters and shall be enclosed py parantheses
       
    37   if necessary.
       
    38 
       
    39     #define MACRO(A, B) \
       
    40         do { \
       
    41             if ((A) == 1) { \
       
    42                 statement(B); \
       
    43         } while (0)
       
    44