Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] Re: simple historian agent
Home

[Freeciv-Dev] Re: simple historian agent

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raimar Falke <i-freeciv-lists@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: simple historian agent
From: nikodimka <nikodimka@xxxxxxxxx>
Date: Sat, 27 Mar 2004 09:43:15 -0800 (PST)

--- Raimar Falke <i-freeciv-lists@xxxxxxxxxxxxx> wrote:
> On Wed, Mar 17, 2004 at 02:53:22PM -0800, nikodimka wrote:
> > 
> > Raimar,
> > 
> > could you please review the simple historian agent initial implementation.
> > It is a simple agent which remembers the last state of all the units, 
> > cities, tiles.
> > 
> > Please see attachment for the details.
> 
> Lets see.
> 
> > struct tile*
> > sha_tile_recall(int x, int y)
> 
> Make the return type const:
>   const struct tile *sha_tile_recall(int x, int y)
> so that no other code changes the struct fields.
> 

Hm. This raised a question (I hope this is not just my ignorance ;) ).
*all* unit related functions in freeciv accept just "struct unit*" types.
compilation -W* flags are very strict so when I would try to call for example 

unit_activity_text(sha_unit_recall()) 

there would be a warning:

warning: passing arg 1 of `unit_activity_text' discards qualifiers from pointer 
target type

and compilation would fail.

the proper type for unit_activity_text and a huge amount of all other functions
not const char *unit_activity_text(struct unit *punit);
but const char *unit_activity_text(const struct unit *punit);
since these functions do not change the incoming unit argument.

so I see three possible solutions:

a) to change signature of counless freeciv functions
b) to make compilation warnings less strict 
c) to make the return type of simple historian agent not const
d) to use (sturct union*) casts right around each sha_unit_recall call which is 
"c)" but uglier.
 
I dislike b and c and have no preference over a or c.

Please tell me that I'm just an idiot and should go read a C language tutorial.

nikodimka

> 
>       Raimar
> 


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html


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