Skip to content

Commit af1b340

Browse files
Matheus MarchiniMylesBorins
Matheus Marchini
authored andcommitted
doc: add C++ style comments to the style guide
Adds instructions on how to format C++ comments to the C++ style guide, as `cpplint.py` doesn't complain about C-style comments on the code. PR-URL: #17617 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
1 parent c3810e2 commit af1b340

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

CPP_STYLE_GUIDE.md

+21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* [Formatting](#formatting)
66
* [Left-leaning (C++ style) asterisks for pointer declarations](#left-leaning-c-style-asterisks-for-pointer-declarations)
7+
* [C++ style comments](#c-style-comments)
78
* [2 spaces of indentation for blocks or bodies of conditionals](#2-spaces-of-indentation-for-blocks-or-bodies-of-conditionals)
89
* [4 spaces of indentation for statement continuations](#4-spaces-of-indentation-for-statement-continuations)
910
* [Align function arguments vertically](#align-function-arguments-vertically)
@@ -33,6 +34,26 @@ these rules:
3334

3435
`char* buffer;` instead of `char *buffer;`
3536

37+
## C++ style comments
38+
39+
Use C++ style comments (`//`) for both single-line and multi-line comments.
40+
Comments should also start with uppercase and finish with a dot.
41+
42+
Examples:
43+
44+
```c++
45+
// A single-line comment.
46+
47+
// Multi-line comments
48+
// should also use C++
49+
// style comments.
50+
```
51+
52+
The codebase may contain old C style comments (`/* */`) from before this was the
53+
preferred style. Feel free to update old comments to the preferred style when
54+
working on code in the immediate vicinity or when changing/improving those
55+
comments.
56+
3657
## 2 spaces of indentation for blocks or bodies of conditionals
3758

3859
```c++

0 commit comments

Comments
 (0)