| OLD | NEW |
| 1 # Chromium C++ style guide | 1 # Chromium C++ style guide |
| 2 | 2 |
| 3 _For other languages, please see the [Chromium style guides](https://chromium.go
oglesource.com/chromium/src/+/master/styleguide/styleguide.md)._ | 3 _For other languages, please see the [Chromium style guides](https://chromium.go
oglesource.com/chromium/src/+/master/styleguide/styleguide.md)._ |
| 4 | 4 |
| 5 Chromium follows the [Google C++ Style | 5 Chromium follows the [Google C++ Style |
| 6 Guide](https://google.github.io/styleguide/cppguide.html) unless an exception | 6 Guide](https://google.github.io/styleguide/cppguide.html) unless an exception |
| 7 is listed below. | 7 is listed below. |
| 8 | 8 |
| 9 A checkout should give you | 9 A checkout should give you |
| 10 [clang-format](https://chromium.googlesource.com/chromium/src/+/master/docs/clan
g_format.md) | 10 [clang-format](https://chromium.googlesource.com/chromium/src/+/master/docs/clan
g_format.md) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 Google style has adopted most C++11 features, but Chromium has a more | 24 Google style has adopted most C++11 features, but Chromium has a more |
| 25 restricted set. The status of C++11 features in Chromium is tracked in the | 25 restricted set. The status of C++11 features in Chromium is tracked in the |
| 26 separate [C++11 use in Chromium](https://chromium-cpp.appspot.com/) page. | 26 separate [C++11 use in Chromium](https://chromium-cpp.appspot.com/) page. |
| 27 | 27 |
| 28 ## Naming | 28 ## Naming |
| 29 | 29 |
| 30 * "Chromium" is the name of the project, not the product, and should never | 30 * "Chromium" is the name of the project, not the product, and should never |
| 31 appear in code, variable names, API names etc. Use "Chrome" instead. | 31 appear in code, variable names, API names etc. Use "Chrome" instead. |
| 32 | 32 |
| 33 * Though the Google C++ Style Guide now says to use `kConstantNaming` for | |
| 34 enums, Chromium was written using `MACRO_STYLE` naming. In enums that are | |
| 35 actually enumerations (i.e. have multiple values), continue to use this | |
| 36 style for consistency. Use `kConstantNaming` when using the "enum hack" to | |
| 37 define a single constant, as you would for a const int or the like. | |
| 38 | |
| 39 * Functions used only for testing should be restricted to test-only scenarios | 33 * Functions used only for testing should be restricted to test-only scenarios |
| 40 either by `#ifdefing` them appropriately (e.g. `#if defined(UNIT_TEST)`) or | 34 either by `#ifdefing` them appropriately (e.g. `#if defined(UNIT_TEST)`) or |
| 41 by naming them with a `ForTesting` suffix. The latter will be checked at | 35 by naming them with a `ForTesting` suffix. The latter will be checked at |
| 42 presubmit time to ensure they're only called by test files. | 36 presubmit time to ensure they're only called by test files. |
| 43 | 37 |
| 44 ## Code formatting | 38 ## Code formatting |
| 45 | 39 |
| 46 * Put `*` and `&` by the type rather than the variable name. | 40 * Put `*` and `&` by the type rather than the variable name. |
| 47 | 41 |
| 48 * When you derive from a base class, group any overriding functions in your | 42 * When you derive from a base class, group any overriding functions in your |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 ## Miscellany | 343 ## Miscellany |
| 350 | 344 |
| 351 * Use UTF-8 file encodings and LF line endings. | 345 * Use UTF-8 file encodings and LF line endings. |
| 352 | 346 |
| 353 * Unit tests and performance tests should be placed in the same directory as | 347 * Unit tests and performance tests should be placed in the same directory as |
| 354 the functionality they're testing. | 348 the functionality they're testing. |
| 355 | 349 |
| 356 * The [C++ do's and | 350 * The [C++ do's and |
| 357 don'ts](https://sites.google.com/a/chromium.org/dev/developers/coding-style/
cpp-dos-and-donts) | 351 don'ts](https://sites.google.com/a/chromium.org/dev/developers/coding-style/
cpp-dos-and-donts) |
| 358 page has more helpful information. | 352 page has more helpful information. |
| OLD | NEW |