/ CodingStyle.md
CodingStyle.md
1 # KNXD Coding Style 2 3 KNXD is written in C++. It has originally been formatted using "indent", 4 which unfortunately knows only C but next to nothing about C++, thus some 5 of the spacing in the code doesn't look at all like idiomatic C++. 6 7 Please try to adhere to the formatting of existing code as much as 8 possible, or at least as much as you're comfortable with. Specifically, 9 please adhere to the two/four-space indent scheme: 10 11 if (x) 12 { 13 more_statements; 14 more_statements; 15 } 16 else 17 single_statement; 18 19 ## "#ifdef"s 20 21 All "#ifdef" statements should be either 22 23 * guard macros (#ifndef foo / #define foo … / #endif) 24 25 * conditional on a specific compiler (cf. "#ifdef __gnuc__" in 26 src/common/types.h) 27 28 * conditional on "HAVE_XXX" as discovered by autoconf. 29 30 Operating system specific conditionals are not allowed: they tend 31 to stop working when you switch compilers, cross-compile, or build 32 with an alternate libc. 33