Skip to content

Commit 929b1d0

Browse files
KarthikNayakgitster
authored andcommitted
Documentation: note styling for bit fields
Our codebase uses a lot of bit field variables, generally to mark boolean type variables. While there is a formatting rule in the '.clang-format', there is no guideline specified in the 'CodingGuidelines'. Since the '.clang-format' is not yet enforced, let's also add a guideline with the same rule as mentioned in the '.clang-format', which is to not use any spaces around the colon, like so: unsigned my_field:1; unsigned other_field:1; unsigned field_with_longer_name:1; This would allow us not to modify the clang-format file, and more importantly, discourage people from doing ugly alignment with spaces, i.e. unsigned my_field : 1; unsigned other_field : 1; unsigned field_with_longer_name : 1; Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c44beea commit 929b1d0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Documentation/CodingGuidelines

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,12 @@ For C programs:
650650
cases. However, it is recommended to find a more descriptive name wherever
651651
possible to improve the readability and maintainability of the code.
652652

653+
- Bit fields should be defined without a space around the colon. E.g.
654+
655+
unsigned my_field:1;
656+
unsigned other_field:1;
657+
unsigned field_with_longer_name:1;
658+
653659
For Perl programs:
654660

655661
- Most of the C guidelines above apply.

0 commit comments

Comments
 (0)