2023-01-06 17:10:33 -08:00
|
|
|
# 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
|
|
|
|
2022-01-24 15:40:21 -08:00
|
|
|
We make with -std=c++11 see [the Makefile](https://github.com/rusefi/rusefi/blob/master/firmware/Makefile)
|
2020-08-26 07:27:11 -07:00
|
|
|
|
|
|
|
## Brackets
|
2023-01-02 11:22:23 -08:00
|
|
|
|
2020-08-26 07:27:11 -07:00
|
|
|
Only the simplest, two-line if/for/while should not have the curly brackets. Anything more than two lines should have {}.
|
|
|
|
|
2023-01-06 17:10:33 -08:00
|
|
|
```c
|
2020-08-26 07:27:11 -07:00
|
|
|
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
|
|
|
|
2020-08-26 07:27:11 -07: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.
|