Libdmapsharing Coding Standards

Libdmapsharing Coding Standards — Description of libdmapsharing's coding standards

Libdmapsharing Coding Standards

  • Use tabs to indent
  • Use spaces to align
  • Attempt to limit lines to 80 characters
  • Use whitespace to keep expressions clear:
    int foo = x + 1 - bar (y);
    
  • In order to protect against an accidental use of assignment in a Boolean expression, use:
    if (CONSTANT == variable)
    not:
    if (variable == CONSTANT)
  • Braces should be formatted as follows:
    if (foo) {
    	something ();
    }
    
    or, in the case of function definitions:
    void foo (void)
    {
    	something ();
    }
    
  • Place a semicolon following function-like preprocessor macros because the lack of one might confuse tools such as indent (even if the semicolon is actually repetitive):
    CPPFUNC(foo);
    
  • Perform a Git commit after finishing a single task
  • Patches submitted should perform one task (e.g., don't add functionality and reformat existing code in the same patch)
  • Git commit messages should be of the following form:

    single line summary with no period

    Optional detailed description. This should use paragraph grammar,
    including periods. This may be any number of lines long. Paragraphs are
    separated by an empty line but are not indented. Lines are less than 80
    characters long.

  • Use GObject conventions for things not covered here
  • You may use the following indent command to format libdmapsharing code:
    indent -i8 -bad -bap -br -ce -d0 -ndj -lp -pcs -psl -sc -sob foo.c