General

  • all names should be descriptive
  • use long descriptive names for top-level names
  • use short names for local names


Variables

  • local: snake_case_all_lower_case
  • extern: PascalCaseWithPrefix
  • static: camelCaseWithOrWithoutPrefix


Functions

  • static: camelCaseWithPrefix
  • global: PascalCaseWithPrefix
  • one function for one task
  • a function should fit one one screen


Types

  • without typedef: Name__T
  • with typedef: Name_t
  • constants/enum member: SNAKE_CASE_ALL_CAPS_WITH_PREFIX


Modules

  • one module for one task group
  • header file contains only minimal information
  • order subordinate modules into subdirectories


Comments

  • Don't use comments unless the they are needed to understand the code.
  • If one needs comments to understand the code, your code is bad and you should feel bad.
  • If you feel bad, update your code and make it more readable.


Formatting Tools

  • Select a coding style and use it for all source files.
  • Use formatting tools like clang-format for automatic formatting.

Last modified: Friday, 1 June 2018, 10:27 AM