Changes between Version 30 and Version 31 of CodingStyle


Ignore:
Timestamp:
Jun 18, 2018, 5:59:46 PM (6 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v30 v31  
    1212 * C++ `.h` files often contain both interface and implementation. Clearly divide these.
    1313
     14=== Error codes === #error-codes
     15
     16 * (Almost) all functions should return an integer error code.
     17   Nonzero means error. See [source:boinc/lib/error_numbers.h lib/error_numbers.h] for a list of error codes.
     18   The only exception to this is PHP database access functions, which use the mysql_* convention
     19   that zero means error, and you call mysql_error() or mysql_error_string() to find details.
     20 * Calls to functions that return an error code should check the code.
     21   Generally they should return non-zero on error, e.g.:
     22{{{
     23retval = blah();
     24if (retval) return retval;
     25}}}
     26
    1427=== Code documentation === #docs
    1528
    16  * `.cpp` files have a comment at the top saying what's in the file (and perhaps what isn't).
     29 * All files have a comment at the top saying what's in the file (and perhaps what isn't).
    1730 * Functions are preceded by a comment saying what they do.
    1831 * structs and classes are preceded by a comment saying what they are.
     
    5164 * There should be few numeric constants in code. Generally they should be `#define`s.
    5265
    53 === Braces === #braces
     66=== Braces (C++ and PHP) === #braces
    5467
    5568 * Opening curly brace goes at end of line (not next line):
     
    7386}}}
    7487
    75 
    7688=== Comments and #ifdefs === #comments
    7789
    78  * Use `//` for all comments.
    79  * Comment out blocks of code as follows:
     90 * For C++ and PHP, use `//` for all comments.
     91 * End multi-line comments with an empty comment line, e.g.
    8092{{{
    81 #if 0
    82     ...
    83 #endif
     93// This function does blah blah
     94// Call it when blah blah
     95//
     96function foo() {
     97}
    8498}}}
    8599
     
    114128 * Dynamic memory allocation.  Functions shouldn't return pointers to malloc'd items.
    115129
    116 === Error codes === #error-codes
    117130
    118  * (Almost) all functions should return an integer error code.
    119    Nonzero means error. See [source:boinc/lib/error_numbers.h lib/error_numbers.h] for a list of error codes.
    120  * Calls to functions that return an error code should check the code.
    121    Generally they should return non-zero on error, e.g.:
    122 {{{
    123 retval = blah();
    124 if (retval) return retval;
    125 }}}
    126131
    127132=== Structure definitions === #structs
     
    137142}}}
    138143
     144=== Comments ===
     145Comment out blocks of code as follows:
     146{{{
     147#if 0
     148    ...
     149#endif
     150}}}
    139151== PHP specific == #php
    140152