-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update C++ style guide #941
Conversation
|
||
We believe that source code should be readable and even beautiful, but that automated formatting is more important than either concern. Especially when readability is largely a matter of what we're used to, and beauty is mostly subjective. For our JavaScript / TypeScript code, we format our code with the ubiquitous [Prettier](https://prettier.io/) tool. In C++, clang-format is widely used but there's no de facto style, and so we've created a clang-format style that tracks as close to Prettier as possible. We will be able to get closer once this [clang-format patch](https://reviews.llvm.org/D33029) is merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will be able to get closer once this clang-format patch is merged.
This will handled in a separate PR to use AlignAfterOpenBracket=BlockIndent
## 🗂️ Other | ||
|
||
Not covered by C++ Core Guidelines. | ||
|
||
* Use `this->` when accessing member variables and functions. This helps distinguish member variables from local variables and member functions from anonymous namespace functions. | ||
* Static function definitions in a .cpp file should be preceded by `/*static*/`. | ||
* Unused parameter names in callbacks should be commented out rather than omitted. Only use `[[maybe_unused]]` when you can't comment out parameter names, such as when parameters are conditionally accessed by `constexpr` logic. | ||
* Use `[i]` instead of `.at(i)` for sequence containers like `std::vector` and `std::array`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered splitting these into separate sections, but it felt like too many extra headings. What do others think?
This all looks good to me! Anyone else want to review before we merge it? |
Seems like a "no"! 😄 |
Preview: https://github.com/CesiumGS/cesium-native/blob/update-style-guide/doc/style-guide.md
Updated the C++ style guide based on internal discussion. For the most part, this is just documenting conventions that already exist in cesium-native.