Michael Petch <mpe...@capp-sysware.com> writes:

> Indentation and spacing is my primary concern. I actually have a
> personal preference for K&R style formatting, although I have been known
> to use the BSD/KNF(and Linux) style as well. The one style I don't
> really like is the GNU style! K&R generally uses tab widths of 4 for
> indentation. Linux kernel style is 8.

> K&R style generally looks like this:

> int main(int argc, char *argv[])
> {
>     ...

One minor point (which you should feel free to ignore, since I'm not an
active code contributor): If you instead write a function definition as:

    int
    main(int argc, char *argv[])

with a newline before the function name, then you have the nice property
that:

    grep ^main *

will show you the definition of any given function without having to
search through all the uses of the function.

Of course, any IDE or tags system will let you do this more easily and
without regard for formatting, but when I'm hacking on code or
investigating some problem, I frequently find that poking about with a
pager, grep, and a UNIX shell is faster than diving into an IDE, so these
sorts of neat tricks can be quite helpful.

-- 
Russ Allbery (r...@stanford.edu)             <http://www.eyrie.org/~eagle/>

_______________________________________________
Bug-gnubg mailing list
Bug-gnubg@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-gnubg

Reply via email to