Changes between Version 4 and Version 5 of CodingStyle


Ignore:
Timestamp:
Jun 19, 2016, 4:35:19 PM (3 years ago)
Author:
Gabriele Pohl
Comment:

Some hints from Christian Franke on coding style

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v4 v5  
    3939unsigned char offl_pending_id;          // ID of offline uncorrectable sector count, 0 if none
    4040}}}
     41
     42=== Some Hints ===
     43
     44A snippet cut out of a mail from Christian Franke on developers list..
     45
     46Due to its long history, many contributors and late move from C to C++, smartmontools is in fact a mixture of different coding styles.
     47
     48In my recent additions I used (or tried to use) the following for new code:
     49
     50{{{
     51Naming:
     52lowercase_underline_lowercase (like C++ std::)
     53
     54Indentation:
     552 Blanks, no tab characters
     56
     57No extra indentation level for {...} blocks
     58
     59No extra line for '{' except for the function body.
     60
     61Lokal variables:
     62C++/C99 declaration statements: First use=declaration=initialization
     63(I really dislike traditional C style with all decls at the beginning of a block :-)
     64
     65Null pointers:
     66"Stroustrup Style": 0 instead of NULL,
     67(T *)0 if needed or compiler check is desired.
     68
     69Checks in boolean style: if (p) ; if (!p) ;
     70
     71In comments: "nullptr" (forward compatible to C++0x :-)
     72
     73Exceptions:
     74Avoid any try/catch blocks if possible, use RAII instead
     75}}}