-
Notifications
You must be signed in to change notification settings - Fork 0
CPP Writing Guidelines
Evan McLaughlin edited this page Jul 3, 2019
·
21 revisions
Generally, we try to stick to the google C++ guide which can be found here:
- Put as many
#includes
as possible in the .cpp file and as little as possible in the .hpp file. The includes in the .cpp are only included when that one file is compiled, but the includes for the .hpp have to be included by every file that uses it.
Via https://stackoverflow.com/questions/3002110/include-in-h-or-c-cpp. - Header include order:
- Header file corresponding to the .cpp file (if applicable).
- Header files from the same component.
- Header files from other components.
- System headers.
Via https://stackoverflow.com/questions/2762568/c-c-include-header-file-order.
- All C++ variables are named with lower case, and underscores between words (e.g., variable_name)
- For private member variables, add an extra underscore at the end of the variable (e.g., private_variable_name_)
- We generally like to access member variables using functions (e.g., GetVariableA(){return A_}). However, you may want to be able to access the member variables for your specific application. For example, point clouds may contain many variables that you often need to access, so in this case you can use public member variables (similar to PCL). For public member variables, do not use an underscore at the end of the variable
- Functions should be named using uppercase letters for each word (e.g., PerformAction())
- Header dependencies should be included in the header file (.h/.hpp) of an object only if that header needs those specific includes. This is usually only variable types that are used for function inputs/outputs and member variables. If includes are only needed for implementation, include those only in the source file (.cpp). Order your includes by most high level to low level to avoid hidden dependencies.
- Home
- Onboarding
- Installation Guide
- Libbeam
- Mapping
- Calibration
- Hardware Instructions
- Deep Learning
- Formatting
- PoTree Maps
- Supported Hardware
- Additional Resources