... | @@ -7,11 +7,20 @@ |
... | @@ -7,11 +7,20 @@ |
|
</a>
|
|
</a>
|
|
</td>
|
|
</td>
|
|
<td style="border-collapse: collapse; border: none; vertical-align: center;">
|
|
<td style="border-collapse: collapse; border: none; vertical-align: center;">
|
|
<b><font size = "5">Braces and Spaces</font></b>
|
|
<b><font size = "5">Braces, Parentheses and Spaces</font></b>
|
|
</td>
|
|
</td>
|
|
</tr>
|
|
</tr>
|
|
</table>
|
|
</table>
|
|
|
|
|
|
|
|
## Table of Contents ##
|
|
|
|
|
|
|
|
1. [Braces](#1-braces)
|
|
|
|
1. [Braces and Comments](#11-braces-and-comments)
|
|
|
|
2. [When braces are needed](#12-when-braces-are-needed)
|
|
|
|
2. [Parentheses and spaces](#1-parentheses-and-spaces)
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
# 1. Braces #
|
|
# 1. Braces #
|
|
|
|
|
|
The following brace placement is recommended:
|
|
The following brace placement is recommended:
|
... | @@ -83,3 +92,28 @@ if (1 == somevalue) somevalue = 2; |
... | @@ -83,3 +92,28 @@ if (1 == somevalue) somevalue = 2; |
|
**Justification**
|
|
**Justification**
|
|
|
|
|
|
It provides safety when adding new lines while maintaining a compact readable form.
|
|
It provides safety when adding new lines while maintaining a compact readable form.
|
|
|
|
|
|
|
|
# 2. Parentheses and spaces #
|
|
|
|
|
|
|
|
Do not put parentheses next to keywords. Put a space between.
|
|
|
|
|
|
|
|
```c
|
|
|
|
if (condition) {
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Do put parentheses next to function names.
|
|
|
|
|
|
|
|
```c
|
|
|
|
strcpy(s, s1);
|
|
|
|
```
|
|
|
|
|
|
|
|
Do not use parentheses in return statements when it's not necessary.
|
|
|
|
|
|
|
|
```c
|
|
|
|
return 1;
|
|
|
|
```
|
|
|
|
|
|
|
|
**Justification**
|
|
|
|
|
|
|
|
Keywords are not functions. By putting parentheses next to keywords and function names are made to look alike. |
|
|
|
\ No newline at end of file |