Skip to content

Commit

Permalink
Merge branch 'jc/coding-style-c-operator-with-spaces' into maint-2.46
Browse files Browse the repository at this point in the history
Write down whitespacing rules around C opeators.

* jc/coding-style-c-operator-with-spaces:
  CodingGuidelines: spaces around C operators
  • Loading branch information
gitster committed Sep 13, 2024
2 parents 4801244 + 44db6f7 commit bb57f05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ For C programs:
v12.01, 2022-03-28).

- Variables have to be declared at the beginning of the block, before
the first statement (i.e. -Wdeclaration-after-statement).
the first statement (i.e. -Wdeclaration-after-statement). It is
encouraged to have a blank line between the end of the declarations
and the first statement in the block.

- NULL pointers shall be written as NULL, not as 0.

Expand All @@ -313,6 +315,13 @@ For C programs:
while( condition )
func (bar+1);

- A binary operator (other than ",") and ternary conditional "?:"
have a space on each side of the operator to separate it from its
operands. E.g. "A + 1", not "A+1".

- A unary operator (other than "." and "->") have no space between it
and its operand. E.g. "(char *)ptr", not "(char *) ptr".

- Do not explicitly compare an integral value with constant 0 or '\0',
or a pointer value with constant NULL. For instance, to validate that
counted array <ptr, cnt> is initialized but has no elements, write:
Expand Down

0 comments on commit bb57f05

Please sign in to comment.