- Declared identifiers MUST be aligned with the function name, using
tabulations only. Hint: Emacs users, use M-I.
The following is wrong:
int foo()
{
int i = 0;
return i;
}
|
|
The following is correct:
int foo()
{
int i = 0;
return i;
}
|
|
- In C, pointerness is not part of the type. Therefore, the pointer symbol
(
*
) in declarations MUST appear next to the variable name, not
next to the type.
The following is incorrect (and probably does not have the intended meaning):
|
The following is correct:
const char *str1;
const char *str2;
|
|
- Structure and union fields MUST be aligned with the type name, using tabulations.
- When declaring a structure or an union, there MUST be only
one field declaration per line.
This is incorrect:
struct s_point
{
int x, y;
long color;
};
|
|
This is correct:
struct s_point
{
int x;
int y;
long color;
};
|
|
- Enumeration values SHOULD be capitalized or reasonably prefixed.
Rationale: the use of common lowercase identifiers is discouraged because it
clobbers the namespace.
- Enumeration values MUST appear on their own lines, properly aligned
with the name of the enumeration.
This is incorrect:
enum e_boolean
{ true, false };
|
|
This is correct:
enum e_boolean
{
b_true,
b_false
};
|
|