11. Alignment

For enhanced readability:

  • Names of variables within a series of definitions (in a .C. file) or declarations (in a .H file) shall have their first characters aligned. (Variable declarations in C do not allocate storage, while variable definitions do.)

    In the case of local variables, left-align names 2 spaces after the longest data type specifier. Example:

    void              function_name(void) {
        storagetask_request_t    lRequestBep;
        BaseType_t               xQueueResult;
        char                   * cp;
        /*      2 spaces --> ^^ ^ <-- 1 space */
    
        ...
    }
    
  • The names of struct and union members shall have their first characters aligned 2 spaces after the longest type specifier.

  • The assignment operators within a sequence of assignment statements shall be aligned.

Further Reading