rusefi_documentation/Code-Style.md

36 lines
757 B
Markdown
Raw Permalink Normal View History

# Code Style Guidelines
2020-05-30 10:43:17 -07:00
* Reduce visibility where possible
2020-05-05 21:45:52 -07:00
2020-05-30 10:43:17 -07:00
* Avoid magic constants
2020-05-05 21:45:52 -07:00
2020-05-30 10:43:17 -07:00
* Please do not push dead code
2020-05-05 21:45:52 -07:00
We make with -std=c++11 see [the Makefile](https://github.com/rusefi/rusefi/blob/master/firmware/Makefile)
## Brackets
2023-01-02 11:22:23 -08:00
Only the simplest, two-line if/for/while should not have the curly brackets. Anything more than two lines should have {}.
```c
if (plain_condition)
oneLineStatement();
if (plain_condition) {
// comment
oneLineStatement();
}
if (plain_condition) {
oneLineStatement();
} else {
oneLineStatement2();
}
```
## Code Formatting
2023-01-02 11:22:23 -08:00
Code formatting matters. The de-facto standard is Eclipse CDT (K&R) with one change: Maximum line width = 120
This standard is far from perfect, but it's good enough for now.