[Freeciv-Dev] Re: Coding Style Guidelines
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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?
- [Freeciv-Dev] Coding Style Guidelines, Mike Kaufman, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines, Teemu Kurppa, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines,
Raimar Falke <=
- [Freeciv-Dev] Re: Coding Style Guidelines, Jason Short, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines, Raimar Falke, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines, Mike Kaufman, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines, Raimar Falke, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines, Chris Richards, 2002/01/11
- [Freeciv-Dev] Re: Coding Style Guidelines, Raimar Falke, 2002/01/12
- [Freeciv-Dev] Re: Coding Style Guidelines, Mike Kaufman, 2002/01/12
- [Freeciv-Dev] Re: Coding Style Guidelines, Ross W. Wetmore, 2002/01/13
- [Freeciv-Dev] Re: Coding Style Guidelines, Tony Stuckey, 2002/01/14
- [Freeciv-Dev] Re: Coding Style Guidelines, Per I. Mathisen, 2002/01/14
|
|