1 Waffle's coding style is heavily influenced by the Linux kernel and XCB.
3 When in doubt, follow the style of nearby code.
8 All symbols exposed in the public API must be prefixed with `waffle_` or
11 No camelCase, itIsSoHardToRead, especiallyWhenTheVariableNameContainsAnUpperCaseAcronym.
13 Function and variable names are lower_case_with_underscores.
15 Enum and macro names are UPPER_CASE_WITH_UNDERSCORES.
20 Non-Doxygen comments begin with '//'. Do not use '/*'-style comments.
21 There are special exceptions, such as when commenting items in a table. Use
24 Doxygen comments begin with '///' or '//!'.
29 Indent 4 spaces. No tabs.
31 Place a function's return type on its own line. This ensures that all function
32 names are aligned and makes it easier to quickly find a function when scanning
36 make_coffee(int x, int y);
38 If a function prototype has a longwinded parameter list, then indent it like this:
42 struct coffee_mug *mug,
43 struct french_press *press,
44 struct sugar_dish *sugar);
49 make_fancy_coffee(struct coffee_mug *mug,
50 struct french_press *press,
51 struct sugar_dish *sugar);
53 Indent cases in switch statements. The last case always requires a jump
54 (break, return, goto).
70 Don't put multiple statements on a single line.
73 if (condition) do_something;
83 Leave no trailing whitespace on end of lines. This can cause spurious commit
86 A single empty line separates function and struct defintions.
88 Do not add spaces inside a parenthesized expression.
92 Place a space after these keywords:
93 if, switch, case, for, do, while
95 For keywords that are typically used as functions, do not follow the keyword
96 with a space and do enclose the arguments with parentheses. The keywords are:
97 sizeof, typeof, alignof, __attribute__
99 When declaring a variable or argument with pointer type, the '*' goes adjacent
100 to the variable or argument name.
104 struct coffee_mug *mug,
105 struct french_press *press,
106 struct sugar_dish *sugar)
108 void *mystery_ingredient = mug + press + sugar;
112 No spaces around unary operators.
116 No spaces around the structure member operators: '.' and '->'.
120 Place a single space before and after the binary operators.