bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] Coding Styles - Indentation / Tabs / Spaces


From: Russ Allbery
Subject: Re: [Bug-gnubg] Coding Styles - Indentation / Tabs / Spaces
Date: Fri, 26 Oct 2012 15:54:19 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Michael Petch <address@hidden> 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 (address@hidden)             <http://www.eyrie.org/~eagle/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]