Complete.Org: Mailing Lists: Archives: freeciv-dev: June 1999:
Re: [Freeciv-Dev] Missing prototypes/#includes
Home

Re: [Freeciv-Dev] Missing prototypes/#includes

[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] Missing prototypes/#includes
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sun, 13 Jun 1999 14:05:51 +1000 (EST)

Andy Black wrote:

> The folowing is an incomplete list of missing prototypes of files that are
> mising the #include for it's header
> 
> Andy Black
> 
> The folowing is a list of funtions in the server setion of the 1.8.0
> stable version
> that do not have prototypes prototypes
> in autoattack.c       (needs #include "autoattack.h", place in autoattack.h)

Yeah, I've just recently fixed cases like this, so that every
.c file should include the corresponding .h file.

>       search_best_target
>       auto_attack_with_unit
>       auto_attack_city
>       auto_attack_player

However for these and the rest, I think most (if not all) are 
functions which are only used in a single file, and where the 
function implementation occurs earlier in the file than where the 
function is called.  For these cases, the function implementation 
provides the prototype, and there is no need to have a separate 
prototype.

That is, as far as the standard C language is concerned, this
is ok.  If your compiler gives an error on this, I consider that a 
problem with your compiler, not with freeciv.  If your compiler 
just gives a warning, maybe you can find a compiler switch to shut 
off such warnings.  

Now one could say that as a matter of style we should include
the prototypes in the .h files anyway.  I would disagree. 
The .h file should define the _interface_ by which code in
other files calls functions in the corresponding .c file.  
By not including the prototypes for internal functions in the
.h file, it is made clear that those functions should not be used 
externally.  (If internal functions need prototypes, the prototypes 
should occur inside the .c file, near the top of the file, IMO.
Having a separate "private" include file is an alternative, but
I don't think necessary, personally.)

To further support/enforce internal functions being internal, such 
functions should arguably be made "static".  Actually, from your 
list of functions, it appears that doing this may turn off the 
warnings/errors you have, since some static functions without 
separate prototypes do not appear in your list.

Your list may be useful if we do decide to make all such
functions static, so thanks for that.

Regards,
-- David

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