Note namespace and static recommendations in C++ style guide (#1041)

This commit is contained in:
Jon Meow
2022-01-27 11:26:47 -08:00
committed by GitHub
parent 086834d63a
commit eda43faa5a
16 changed files with 48 additions and 49 deletions
+9
View File
@@ -141,6 +141,15 @@ these.
necessary to create a scope for a variable.
- Always break the line immediately after an open brace except for empty
loop bodies.
- For
[internal linkage](https://google.github.io/styleguide/cppguide.html#Internal_Linkage)
of definitions of functions and variables, prefer `static` over anonymous
namespaces. `static` minimizes the context necessary to notice the internal
linkage of a definition.
- Anonymous namespaces are still necessary for classes and enums.
- Tests are an exception and should typically be wrapped with
`namespace Carbon::Testing { namespace { ... } }` to keep everything
internal.
### Copyable and movable types