Skip to content

Commit 27d4f40

Browse files
committed
Merge branch 'jc/coding-style-c-operator-with-spaces'
Write down whitespacing rules around C opeators. * jc/coding-style-c-operator-with-spaces: CodingGuidelines: spaces around C operators
2 parents 3222718 + 44db6f7 commit 27d4f40

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Documentation/CodingGuidelines

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ For C programs:
303303
v12.01, 2022-03-28).
304304

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

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

@@ -323,6 +325,13 @@ For C programs:
323325
while( condition )
324326
func (bar+1);
325327

328+
- A binary operator (other than ",") and ternary conditional "?:"
329+
have a space on each side of the operator to separate it from its
330+
operands. E.g. "A + 1", not "A+1".
331+
332+
- A unary operator (other than "." and "->") have no space between it
333+
and its operand. E.g. "(char *)ptr", not "(char *) ptr".
334+
326335
- Do not explicitly compare an integral value with constant 0 or '\0',
327336
or a pointer value with constant NULL. For instance, to validate that
328337
counted array <ptr, cnt> is initialized but has no elements, write:

0 commit comments

Comments
 (0)