Can I reformat your code?

James LewisMoss jimdres@mindspring.com
25 Jul 2001 11:46:50 -0400


>>>>> On Wed, 25 Jul 2001 07:57:09 -0500, grib@billgribble.com (Bill Gribble) said:

 Bill>     [ ... ]

All this is good.  The only thing I don't like is the -p.h
convention.  Better IMO to just make everything that can be public,
but I'm more than willing to go along with everyone else here.

 Bill> Brace styles: As you can tell by the examples above, I write
 Bill> all my code in the venerable 1TBS with 2-space indents. I'm
 Bill> willing to change, but I like it like that.  1TBS is the "one
 Bill> true brace style":

 Bill>   if(foo) {
 Bill>     bar;
 Bill>   } else {
 Bill>    baz;
 Bill>   }

I find this hard to read with 2 space indents, but it's ok.

 Bill> My understanding of GNU style is that it's

 Bill>   if(foo)
 Bill>     {
 Bill>       bar;
 Bill>     }
 Bill>   else
 Bill>     {
 Bill>       baz;
 Bill>     }

Blech.

 Bill> which I strongly object to.  I also can't really stand anything
 Bill> that has } else { in it, but neither can most people.  Most
 Bill> *normal* people, that is :)

 Bill>   if(foo) {
 Bill>     bar;
 Bill>   } else {
 Bill>     baz;
 Bill>   }

 Bill> is much better and I can live with it if people hate 1TBS.

Looks like my stuff reindented stuff, but this is what I prefer.

 Bill> Parens and spacing: I like spaces around arithmetic operators,
 Bill> complete parenthesization in math expressions, and no spaces
 Bill> padding parens.  i.e.

 Bill>   if((a * b) + (b * c)) {

 Bill> not
 
 Bill>   if ( a*b+b*c ) {

Agreed.

 Bill> Function prototype: function names in their definitions should
 Bill> start in the leftmost column.

 Bill> int foo(int bar, int baz) {

 Bill> not

 Bill> int foo(int bar, int baz) {

Whatever the case with the braces with if's and while's no brace
should be at the end of a function def.  It should always be on the
next line.

 Bill> C Macros considered harmful: C macros are code obfuscators.  If
 Bill> you need extensive macros, you need to redesign your code, IMO.

agreed.

Jim

-- 
@James LewisMoss <dres@debian.org>      |  Blessed Be!
@    http://jimdres.home.mindspring.com |  Linux is kewl!
@"Argue for your limitations and sure enough, they're yours." Bach