Skip to content
meag edited this page Mar 31, 2017 · 1 revision

Coding Standards

ezQuake has essentially been in development over 20 years, with various teams and programmers contributing code at various times. This leads to situation where the layout is inconsistent across different files.

All new code should follow the style guidelines below. When making changes to existing code, either convert to this style or at least make sure it's consistent with the other code in the file.

Guidelines

  • Always use tabs for indentation, and spaces for alignment
  • Functions without parameters should be explicitly declared (void)
  • C89 variable-declarations - always declare at top of block
  • { should generally not go on a newline (exception for function blocks)
  • } always on a newline
  • else should go on on a newline, not following the previous }.

Examples:

int FunctionName(void)
{
    if (test1) {
    }
    else if (test2) {
    }
    else {
    }
    return 0;
}

typedef struct myStruct_s {
    int         myVal1;            // comment
    float       last_time_set;     // comment2
//^tabs    ^spaces              ^spaces
} client_t;