Node:Formatting code, Next:, Previous:Style, Up:Style



Formatting code

Place the open curly bracket that starts the body of a C function in the first column of your source file, and avoid placing any other open brackets or open parentheses in that column. This will help many code-processing utilities find the beginnings of your functions. Similarly, you should also place the name of your functions within your function definitions in the first column. Thus, your functions should resemble the following example:

static char *
concat (char *s1, char *s2)
{
  ...
}

When you split an expression into multiple lines, split it before an operator, not after one. Here is the right way:

if (foo_this_is_long && bar > win (x, y, z)
    && remaining_condition)

Don't declare multiple variables in one declaration that spans lines. Start a new declaration on each line instead. For example, instead of this:

int    foo,
       bar;

write either this:

int foo, bar;

or this:

int foo;
int bar;