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: schaefer@xxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Programing style
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Thu, 10 Jun 1999 12:03:42 +1000

Peter Schaefer wrote:

> I've run make with gcc -pedantic -Wmissing-prototypes.
> Output is attached.

> In file included from city.c:21:
> log.h:100: warning: ANSI C does not allow macro with variable arguments

Which is why we explicitly only use macros with variable arguments 
when we know that we're using gcc.

> gcc -Wmissing-prototypes -pedantic -DHAVE_CONFIG_H -I. -I. -I..   -g -O2 
> -Wall -c game.c
> In file included from game.c:22:
> game.c:302: warning: no previous prototype for `initialize_globals'

Ah, this one is because we have a prototype in game.h (which is
included), but the prototypes has an empty argument list:
   void initialize_globals();
where it should have instead
   void initialize_globals(void);
(the two are _not_ equvialent).  I've been meaning to fix such cases.

> gcc -Wmissing-prototypes -pedantic -DHAVE_CONFIG_H -I. -I. -I..   -g -O2 
> -Wall -c map.c
> map.c:559: warning: no previous prototype for `tile_move_cost_ptrs'

Here the implementation of tile_move_cost_ptrs occurs before
tile_move_cost_ptrs is used, and the implementation can act
as a prototype, so I consider this warning spurious.
Though such functions could (should?) be made "static".

> In file included from /usr/include/sys/socket.h:34,
>                  from /usr/include/netinet/in.h:24,
>                  from packets.c:19:
> /usr/include/socketbits.h:173: warning: ANSI C forbids zero-size array 
> `__cmsg_data'

Not much we can do about system includes.

> gcc -Wmissing-prototypes -pedantic -DHAVE_CONFIG_H -I. -I. -I..   -g -O2 
> -Wall -c unit.c
> In file included from unit.c:23:
> unit.c: In function `best_role_unit':
> unit.c:1128: warning: `u' might be used uninitialized in this function

This is an interesting one, which I've noticed before.  The warning
doesn't make sense looking at the code, it goes away if you turn
off -O2, and it didn't occur with older version of gcc.  Seems like
a gcc bug to me.  I did actually isolate a small program which 
reproduces the warning, but then didn't get around to doing anything
about it.

So does anyone want to work out whether there any _useful_ 
warnings of missing prototypes in that huge amount of output?

-- David

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