Welcome to the C/C++ Project Style Guide. This guide outlines the coding standards and best practices to be followed by contributors to maintain consistency and high-quality code across the project.
Use 4 spaces for indentation; do not use tabs.
Limit each line of code to a maximum of 80 characters for improved readability.
- Identifiers (functions, variables): Use
camelCase
. - Classes/Structs: Begin with a capital letter and use
PascalCase
. - Functions and variables: Begin with lowercase letters and use
camelCase
.
Use the K&R style for braces:
if (condition) {
// code
}
else {
// code
}
Avoid writing program code in header files. Place only declarations and small inline functions in headers. Main code should be in the corresponding source files (.c or .cpp) to ensure modularity and prevent potential issues.
Add headers to CMakeLists.txt when required
All header files must include header guards to prevent multiple inclusions. Use the following format:
#ifndef HEADER_NAME_H
#define HEADER_NAME_H
// Content of the header
#endif // HEADER_NAME_H
Maintain an up-to-date and informative README.md at the root of the repository. Include details such as:
- Project overview
- Installation instructions
- Usage examples
- Plans
- Configuration details
- Contribution guidelines
- License information
- Never directly commit to the
main
branch. - Create a branch for each feature/bugfix using descriptive names.
- Push branches to the remote repository and open pull requests.
- Use the following branches:
main
: Stable production-ready code.develop
: Integration branch for upcoming releases.- Feature branches: Created off
develop
and merged back after development.
- Write clear and descriptive commit messages.
- For minor patches, a concise message is acceptable.
- Use the rebase strategy to keep commit history clean before merging.
- Create pull requests from feature/bugfix branches to
develop
. - Provide detailed descriptions of changes.
- Require code reviews before merging.