Skip to content

Commit 92aad53

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21930: doc: update enumerator naming in developer notes
77f37f5 doc: update enum naming in developer notes (Jon Atack) Pull request description: Per our current doc, the general rule is we follow the C++ Core Guidelines, which for enumerator naming stipulate: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps ``` Don’t use ALL_CAPS for enumerators Reason: Avoid clashes with macros. ``` but our examples (and often, codebase) are contradictory to it (and perhaps to common usage), which can be confusing when a contributor needs to choose a style to use. This patch: - updates the enumerator examples to snake_case per CPP Core Guidelines - clarifies for contributors that in this project enumerators may be snake_case, PascalCase or ALL_CAPS, and to use what seems appropriate. ACKs for top commit: practicalswift: cr ACK 77f37f5 ryanofsky: ACK 77f37f5. I think this is good because it modernizes the example and clarifies current conventions. promag: ACK 77f37f5. Tree-SHA512: 7facc607fe5e1abab0f635864340143f13c2e4bb074eb17eac7d829dcd0cf244c5c617fc49d35e8774e8af1fa1205eeebe0cca81f538a2a61f6a7ba200878bc6
2 parents a8fdfea + 77f37f5 commit 92aad53

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/developer-notes.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ code.
8989
- Class member variables have a `m_` prefix.
9090
- Global variables have a `g_` prefix.
9191
- Constant names are all uppercase, and use `_` to separate words.
92+
- Enumerator constants may be `snake_case`, `PascalCase` or `ALL_CAPS`.
93+
This is a more tolerant policy than the [C++ Core
94+
Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps),
95+
which recommend using `snake_case`. Please use what seems appropriate.
9296
- Class names, function names, and method names are UpperCamelCase
9397
(PascalCase). Do not prefix class names with `C`.
9498
- Test suite naming convention: The Boost test suite in file
@@ -669,19 +673,19 @@ Foo(vec);
669673

670674
```cpp
671675
enum class Tabs {
672-
INFO,
673-
CONSOLE,
674-
GRAPH,
675-
PEERS
676+
info,
677+
console,
678+
network_graph,
679+
peers
676680
};
677681

678682
int GetInt(Tabs tab)
679683
{
680684
switch (tab) {
681-
case Tabs::INFO: return 0;
682-
case Tabs::CONSOLE: return 1;
683-
case Tabs::GRAPH: return 2;
684-
case Tabs::PEERS: return 3;
685+
case Tabs::info: return 0;
686+
case Tabs::console: return 1;
687+
case Tabs::network_graph: return 2;
688+
case Tabs::peers: return 3;
685689
} // no default case, so the compiler can warn about missing cases
686690
assert(false);
687691
}

0 commit comments

Comments
 (0)