Changes between Version 28 and Version 29 of CodingStyle


Ignore:
Timestamp:
Aug 30, 2016, 2:00:17 PM (8 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v28 v29  
    7676=== Comments and #ifdefs === #comments
    7777
    78  * Use `///` for all comments. The documentation is generated using Doxygen, so you should have a look at this example:
    79 
    80 {{{
    81 /// Brief description for class test.
    82 
    83 /// A more elaborate description for class test,
    84 /// could be more than one line.
    85 class Test
    86 {
    87   public:
    88 
    89     /// A constructor.
    90      
    91     /// A more elaborate description of the constructor.
    92     Test();
    93 
    94     /// A destructor.
    95     /// A more elaborate description of the destructor.
    96     ~Test();
    97    
    98     /// a normal member taking two arguments and returning an integer value.
    99     /// @param a an integer argument.
    100     /// @param s a constant character pointer.
    101     /// @see Test()
    102     /// @see ~Test()
    103     /// @see testMeToo()
    104     /// @see publicVar()
    105     /// @return The test results
    106     int testMe(int a,const char *s);
    107        
    108     /// A pure virtual member.
    109     /// @see testMe()
    110     /// @param c1 the first argument.
    111     /// @param c2 the second argument.
    112     virtual void testMeToo(char c1,char c2) = 0;
    113    
    114     /// a public variable.
    115 
    116     /// Details.
    117     int publicVar;
    118        
    119     /// a function variable.
    120 
    121     /// Details.
    122     int (*handler)(int a,int b);
    123 };
    124 
    125 }}}
    126 
     78 * Use `//` for all comments.
    12779 * Comment out blocks of code as follows:
    12880{{{
     
    13688=== Includes === #includes
    13789
    138  * A `.cpp` file should have the minimum set of #includes to get that particular file to compile (e.g. the includes needed by `foo.cpp` should be in `foo.cpp`, not `foo.h`).
    139  * `foo.cpp` should include `foo.h` first; after that, includes should be ordered from general (`<stdio.h>`) to specific (`shmem.h`).
     90 * A `.cpp` file should have the minimum set of #includes to get that particular file to compile
     91  (e.g. the includes needed by `foo.cpp` should be in `foo.cpp`, not `foo.h`).
     92 * For readability, includes should be ordered from general (`<stdio.h>`) to specific (`foo.h`).
     93  However, this order shouldn't matter.
    14094
    14195=== Extern declarations === #extern
    14296
    143  * `foo.h` should have `extern` declarations for all public functions and variables in `foo.cpp` There should be no `extern` statements in `.cpp` files.
     97 * `foo.h` should have `extern` declarations for all public functions and variables in `foo.cpp`
     98   .There should be no `extern` statements in `.cpp` files.
    14499
    145100=== Use of static === #static
     
    147102 * If a function or variable is used in only one file, declare it `static`.
    148103
    149 === Things to avoid unless there's a truly compelling reason: === #try-avoid
     104=== Things to avoid unless there's a compelling reason: === #try-avoid
    150105
    151106 * Operator or function overloading.
     
    155110
    156111 * Use `typedef` (not `#define`) to define types.
    157  * Don't use `memset()` or `memcpy()` to initialize or copy classes that are non-C compatible. Write a default constructor and a copy constructor instead.
     112 * Don't use `memset()` or `memcpy()` to initialize or copy classes that are non-C compatible.
     113   Write a default constructor and a copy constructor instead.
    158114
    159115=== Error codes === #error-codes
    160116
    161  * (Almost) all functions should return an integer error code. Nonzero means error. See [source:boinc/lib/error_numbers.h lib/error_numbers.h] for a list of error codes.
    162  * Calls to functions that return an error code should check the code. Generally they should return non-zero on error, e.g.:
     117 * (Almost) all functions should return an integer error code.
     118   Nonzero means error. See [source:boinc/lib/error_numbers.h lib/error_numbers.h] for a list of error codes.
     119 * Calls to functions that return an error code should check the code.
     120   Generally they should return non-zero on error, e.g.:
    163121{{{
    164122retval = blah();