Fork us on GitHub Follow us on Facebook Follow us on Twitter

Version 1 (modified by Martin Decky, 7 years ago) (diff)

copy cstyle standard from the old Drupal page

HelenOS Coding Style Standard

Entity Naming

  • Names' words shall be separated by underscore "_".
  • Types shall be suffixed with "_t".
  • Macros shall be upper case.

Names

  • Use sensible, descriptive names.
  • Only use English names.
  • Variables with a large scope should have long names, variables with a small scope can have short names.
  • Use name prefixes for identifiers declared in different modules.

Indentation and Spacing

  • Do not use spaces for indentation, except for long line wrapping purposes.
  • Consider breaking long lines at 80-character boundary. The wrapped line should continue indented four spaces to the right of the original indentation.
  • Braces shall follow "K&R Bracing Style".
  • Braces shall be indented 1 tab to the right of the starting position of the enclosing statement or declaration.
  • Braces without any contents may be placed on the same line.
  • Each statement shall be placed on a line on its own.
  • All binary arithmetic, bitwise and assignment operators and the ternary conditional operator (?:) shall be surrounded by spaces; the comma operator shall be followed by a space but not preceded; all other operators shall not be used with spaces.

Comments

  • Comments shall be written in English.
  • Multiline comments begin with "*" on each inner line.
  • Use Doxygen style comments for documenting functions.
  • All comments shall be placed above the line the comment describes, indented identically.
  • Every function shall have a comment that describes its purpose.

Miscellaneous

  • New lines are represented by the LF ('\n') character. Do not use CR + LF or CR.