C编程规范--格式:布尔表达式

Boolean Expression

布尔表达式

When you have a boolean expression that is longer than the standard line length, be consistent in how you break up the lines.

当你有一个布尔表达式比标准的行长,在你如何分割行是一致的。

In this example, the logical AND operator is always at the end of the lines:

例如,逻辑与操作符&&总是在行尾

if (this_one_thing > this_other_thing &&

    a_third_thing == a_fourth_thing &&

    yet_another && last_one) {

  ...

}

Note that when the code wraps in this example, both of the && logical AND operators are at the end of the line. This is more common in Google code, though wrapping all operators at the beginning of the line is also allowed. Feel free to insert extra parentheses judiciously because they can be very helpful in increasing readability when used appropriately. Also note that you should always use the punctuation operators, such as && and ~, rather than the word operators, such as and and compl.

注意当代码在这个示例中包装时,逻辑与操作符总是在行尾的。这在google代码中很常见,不过在行首包装所有操作符也是可行的。可以随意明智地插入额外的圆括号,因为如果使用得当,它们对于提高可读性非常有帮助。另外还需要注意的是,应该始终使用标点操作符,如&&和~,而不是单词操作符,如and和compl。

你可能感兴趣的:(C语言,C,编程规范,布尔表达式)