Skip to content

Commit cabf144

Browse files
refackjasnell
authored andcommitted
doc,meta: add references to outside C++ guides
with explicit priorities PR-URL: #23317 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 1143ea8 commit cabf144

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

CPP_STYLE_GUIDE.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Table of Contents
44

5+
* [Guides and References](#guides-and-references)
56
* [Formatting](#formatting)
67
* [Left-leaning (C++ style) asterisks for pointer declarations](#left-leaning-c-style-asterisks-for-pointer-declarations)
78
* [C++ style comments](#c-style-comments)
@@ -25,14 +26,30 @@
2526
* [Avoid throwing JavaScript errors in C++ methods](#avoid-throwing-javascript-errors-in-c)
2627
* [Avoid throwing JavaScript errors in nested C++ methods](#avoid-throwing-javascript-errors-in-nested-c-methods)
2728

28-
Unfortunately, the C++ linter (based on
29-
[Google’s `cpplint`](https://github.com/google/styleguide)), which can be run
30-
explicitly via `make lint-cpp`, does not currently catch a lot of rules that are
31-
specific to the Node.js C++ code base. This document explains the most common of
32-
these rules:
29+
30+
## Guides and References
31+
32+
The Node.js C++ codebase strives to be consistent in its use of language
33+
features and idioms, as well as have some specific guidelines for the use of
34+
runtime features.
35+
36+
Coding guidelines are based on the following guides (highest priority first):
37+
1. This document
38+
2. The [Google C++ Style Guide][]
39+
3. The ISO [C++ Core Guidelines][]
40+
41+
In general code should follow the C++ Core Guidelines, unless overridden by the
42+
Google C++ Style Guide or this document. At the moment these guidelines are
43+
checked manually by reviewers, with the goal to validate this with automatic
44+
tools.
3345

3446
## Formatting
3547

48+
Unfortunately, the C++ linter (based on [Google’s `cpplint`][]), which can be
49+
run explicitly via `make lint-cpp`, does not currently catch a lot of rules that
50+
are specific to the Node.js C++ code base. This document explains the most
51+
common of these rules:
52+
3653
### Left-leaning (C++ style) asterisks for pointer declarations
3754

3855
`char* buffer;` instead of `char *buffer;`
@@ -304,4 +321,8 @@ not inside of nested calls.
304321

305322
Using C++ `throw` is not allowed.
306323

324+
325+
[C++ Core Guidelines]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
326+
[Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html
327+
[Google’s `cpplint`]: https://github.com/google/styleguide
307328
[errors]: https://github.com/nodejs/node/blob/master/doc/guides/using-internal-errors.md

0 commit comments

Comments
 (0)