Skip to content
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

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Update C++ style guide #941

merged 2 commits into from
Sep 9, 2024

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Aug 27, 2024

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.


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.
Copy link
Contributor Author

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

Comment on lines +149 to +156
## 🗂️ 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`.
Copy link
Contributor Author

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?

@kring
Copy link
Member

kring commented Aug 29, 2024

This all looks good to me! Anyone else want to review before we merge it?

@kring
Copy link
Member

kring commented Sep 9, 2024

Seems like a "no"! 😄
Merging!

@kring kring merged commit a826502 into main Sep 9, 2024
24 checks passed
@kring kring deleted the update-style-guide branch September 9, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants