Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: Coding Style Guidelines
Home

[Freeciv-Dev] Re: Coding Style Guidelines

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>
Cc: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Coding Style Guidelines
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Jan 2002 09:39:30 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Jan 11, 2002 at 12:17:14AM -0600, Mike Kaufman wrote:
> attached is what I propose to be put in CVS. Hopefully this will start
> the last major thread on this subject. I welcome feedback.
> 
> There are a couple of things that need to be discussed:
> 
> I did not put this into the guideline:
> 
> /***********************************
>  * 3: comments in code (see also 9:)
>  ***********************************/
> 
> /* A */
> int foo3a(int x)
> {
>   x = 3;    /* assign 3 to x */
> }
> 
> /* B */
> int foo3b(int x)
> {
>   /* assign 3 to x */
>   x = 3;
> }

> because there is some level of contradiction between this and what
> people wanted in the Comments in declarations. Do people still think that A is
> unacceptable here? My opinion is that A is fine anytime you can fit it on a
> single line.

No. It is more that comment should always above. The exception are
enums and struct declarations.

> - Spaces should go before and after operators, and after commas:

indent takes care of this.

> - Every function should have a comment header like:

Can you include "This comment is above the implementation and not in
the header file."? Just to be sure.

> - Comments which take more than one line. Asterisks should be placed in
>   front of the comment line like so:
> 
>   /* I am a comment
>    * blah blah 
>    * blah blah */

We also discussed:

   /* 
    * I am a comment
    * blah blah
    * blah blah 
    */

But haven't voted for it IMHO.

> - Function braces should begin and end in the first column:
> 
> int foo()
> {
>   return 0;
> }
> 
>  and not:
> 
> int foo() {
>   return 0;
> }

AFAIK indent takes care of this.

> - If an empty block is needed, 

> a simple semicolon is sufficient

No.

> , but you 
>   may wish to put an explanatory comment:
> 
>   while(*i++);
> 
>  or
> 
>   while(*i++) {
>     /* nothing */
>   }

> - Always prototype global functions in the appropriate header file.
>   Local functions should always be declared as static.

Use "-Wmissing-prototypes -Wmissing-declarations" to catch these.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Windows: Where do you want to go today?
 Linux: Where do you want to go tomorrow?
 BSD: Are you guys coming or what?


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