"Fossies" - the Fresh Open Source Software Archive

Member "netxms-3.1.300/doc/internal/coding_style.txt" (7 Jan 2020, 1801 Bytes) of package /linux/misc/netxms-3.1.300.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "coding_style.txt" see the Fossies "Dox" file reference documentation.

    1 1. Each word in function name should start with capital letter. No underscores.
    2    For exaple: CreateNewUser. Underscores allowed in parameter handlers,
    3    which can start with "H_" prefix, like this: H_FreeDiskSpace.
    4 
    5 2. Indentation offset: 3
    6 
    7 3. Opening { should be placed on next line without indentation, like below:
    8 
    9    if (a < b)
   10    {
   11       something();
   12    }
   13 
   14 4. Operators and operands should be separated by spaces, like below:
   15 
   16    a = x + 20 / (y - z);
   17  
   18 5. Function arguments should be separated by spaces, like below:
   19  
   20    z = function(p1, p2, p3);
   21  
   22 6. One-line comments should be placed with the same indentation level as code,
   23    like this:
   24  
   25    c = xxx();
   26    if (a)
   27    {
   28       // comment
   29       func();
   30    }
   31  
   32 7. Brackets after for and while operators may or may not be separated by
   33    spaces (I prefer not to separate them, but it's not a big problem IMHO).
   34  
   35 8. Variable names preferrably should start with type specifier. For example,
   36    DWORD variable "index" should be called "dwIndex". Below is a common type
   37    prefixes:
   38  
   39    dw - DWORD
   40    i - int
   41    n - long
   42    qw - QWORD
   43    d - double
   44    tm - time_t
   45    sz - String (TCHAR [])
   46    psz - Pointer to string (TCHAR *)
   47    p - Generic pointer
   48    p<data type> - Pointer to variable of type <data type> (like DWORD *pdwIndex;)
   49  
   50    If variable is of custom type, it can have no prefix, and it's name should
   51    start with small letter. For example:
   52  
   53    struct stat fileStat;
   54  
   55 9. It is recommended to use typedefs as a replacement for some system
   56    data types:
   57       WORD  - unsigned short (16 bit unsigned integer)
   58       LONG - instead of system's 32 signed integer
   59       DWORD - unsigned long (32 bit unsigned integer)
   60       INT64 - instead of system's 64 bit signed integer
   61       QWORD - instread of system's 64 bit unsigned integer