|
Apache DevelopersC Language Style Guide -- 最优代码风格(我认为)(3) Function Calls Space after commas in function calls. No space between function name and opening bracket. f(a, b); Also see the section on indenting long declarations and invocations. Flow-Control Layout Flow-control statements (if, while, for, etc.) are laid out as in this example: if (expr) {code; } else {code; }There is a space between the keyword and the opening bracket. Opening brace placed on same line as the flow keyword. The code itself is indented by four spaces. The closing brace is indented to line up with the opening brace. If an else clause is used, the else keyword is placed on the line following the closing brace and is indented to line up with the corresponding if. Also see the section on indenting long expressions. for Layout Space after the semi-colons. Example: for (a; b; c) switch Layout case lines within a switch() are indented to same level as the switch statement itself. The code for each case is indented by four spaces. Braces are laid out as for other control-flow keywords. Example: switch (x) { case a:code; case b:code; }Expressions Space before and after assignment and other and operators. No space between unary operators (increment, decrement, and negation) and the lvalue. Examples: a = b a + b a < b a = -b a = !b ++a Capitalisation of Enums No rule.
|