[pisa] Re: Reformatting and coding style

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa@xxxxxxxxxxxxx
  • Date: Fri, 04 Dec 2009 02:25:43 +0100

On Wed, Dec 02, 2009 at 06:52:29PM +0100, Tobias Heer wrote:
> 
> This is a quick roundup of the changes that were made. A proper coding
> style will be provided as of thursday.
>
> 1) General K&R style 
> 2) Tabwidth 4 spaces, use spaces for indentation only
> 3) Strict braces (braces for every conditional statement) e.g., 
> 
> if( a == 2 ) {

style 1)

>     if ( c == 1) {

style 2)

> instead of:
> 
> if (a == 2)

style 3)

>     if( c == 1)

style 4)

hint: style 2) is K&R, the others are not.  I'll write up the document
real soon now.  I got sidetracked with header cleanup and meetings
today...

short and sweet:

- no tabs, no trailing whitespace, 4 spaces indent
- space between keywords and (, except for sizeof
- no space between function names and (
- space between } and (
- spaces around operators
- no space padding inside ()
- spaces after ,
- { on the same line as for/if/while/switch/do with a space between )
  and {
- } and else/while on the same line
- { on the next line for function declarations
- type on the same line as function name
- case indented at the same level as switch
- long lines past 80 characters broken at suitable places
- function arguments placed on the next line align the first character
  after the (

Diego

Other related posts: