Standard Indentation etc.
Peter Desnoyers
desnoyer at Apple.COM
Fri Dec 16 06:21:18 AEST 1988
My preference is :
if (<expr>)
{
...statement
...
}
(plus various other things) I only feel strongly about a few
indentation issues:
(1) except in very special cases 'if (<expr>) statement' should take
2 lines. Same goes for single-statement cases in a switch.
(2) Gnuemacs can't find the beginning or end of a function unless the
first and last braces are flush with the beginning of the line.
Like everyone else said, having an indentation standard is more
important than what the standard says. However, when you get into the
topic of function and module headers, you will probably find more of a
religious war, as everyone feels that their way is the one of truth,
rather than just a bit more valid than everyone else's.
These standards are crucial - you can't run code through a
pretty-printer and get comments out. My feeling is that they should
be flexible - decide on a list of things which can be described about
functions, data structures, modules, etc. (e.g. function arguments,
return value, side effects, global dependencies, references,
description.) Then only require those elements relevant to a
particular function be put in that function's header.
That approach is close to what I find myself doing. It also avoids the
trap mentioned in a previous discussion of coding standards - someone
worked at a place where the mandatory function headers were so long
that people combined functions to avoid writing headers.
Peter Desnoyers
More information about the Comp.lang.c
mailing list