Complete.Org: Mailing Lists: Archives: freeciv-dev: June 1999:
Re: [Freeciv-Dev] Programing style
Home

Re: [Freeciv-Dev] Programing style

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ablack@xxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Programing style
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Wed, 9 Jun 1999 12:33:13 +1000 (EST)

Andy Black wrote:

> During my work I have noticed several programing style problems
> 1. useage of #include <...> for freeciv headers
>       I do not know if linux compilers suport this, but I belive that
> normal synax for project headers is #include "..." and the normal syntax
> for system headers is #include <...>

This has been discussed a few times before.  I don't want to go
_again_ into the technical details of <> versus "", but as far 
as the standard C language is concerned, what we are doing is fine.  

It is however true that the way we do it goes against a common
convention, and the conventional way would also be fine C-wise.
I think there was general agreement that the conventional way 
would be better, but no-one has gone through and changed everything 
yet.  (Some individual files follow the conventional way.)

> 2. location of #includes
>       It is easier to identify the source of a header if the system
> headres are in one block and the project headers are in another block.

Agreed.

> 3. lack of function prototypes
>       This is a minor problem that generates errors that can be turned
> off

I consider missing prototypes a serious problem; please report any
such.  If they are system prototypes, that could be more difficult 
to deal with, but could also indicate portability issues we need 
to deal with.

> 4. inplicit enum conversions
>       implicit enum conversions ar things like feeding an int to a
> function that requires an enum or returning an int where an enum is
> wanted.
>       one major source is the currently_building item in the city
> struct. if c suports unions, I would do the folowing:

Yes, this would be possible, but ultimately we would still need to 
convert between ints and enums in some places, because we need to 
send enum values over-the-wire as integers. 

Since in C, enums really do correspond directly to integers,
I don't see a real problem in converting between the two, 
though it would be good practice to use the explicit enum types 
where feasible.  Whether its worth converting stuff to use
unions I'm not sure.

Regards,
-- David

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