Development:Code Style

From rusEfi
Jump to: navigation, search

We make with -std=c++11 see https://github.com/rusefi/rusefi/blob/master/firmware/Makefile


Brackets

Only the simplest, two-line if/for/while should not have the curly brackets. Anything more than two lines should have {}.

if (plain_condition)
   oneLineStatement();

if (plain_condition) {
   // comment
   oneLineStatement();
}

if (plain_condition) {
   oneLineStatement();
} else {
   oneLineStatement2();
}  

Code Formatting

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.