gnushogi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnushogi-devel] Use of "bool" type


From: Yann Dirson
Subject: [Gnushogi-devel] Use of "bool" type
Date: Mon, 26 May 2014 00:43:47 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

While looking at code impacted by recent patches, I realized many
things would be clearer if we were using a visibly-boolean type.

Branch yd/wip/bool does that, and adds notes about strange things
discovered while playing with bools - that is, those that I did not
fix already in other branches (both master and maint-pu got a couple
of fixes).

All of this is in "pu", but there is an annoying side-effect:

../../gnushogi/commondsp.c: In function ‘ParseAndExecuteCommand’:
../../gnushogi/commondsp.c:2037:17: warning: format ‘%hd’ expects argument of 
type ‘short int *’, but argument 3 has type ‘_Bool *’ [-Wformat=]
                 if (sscanf(sx, "option tsume=%hd", &flag.tsume) == 1)
                 ^
../../gnushogi/commondsp.c:2039:17: warning: format ‘%hd’ expects argument of 
type ‘short int *’, but argument 3 has type ‘_Bool *’ [-Wformat=]
                 if (sscanf(sx, "option hash=%hd",  &flag.hash) == 1)
                 ^

I have not addressed this yet, but as the only compilation warning in
pu it should not get forgotten.

In fact, making "struct flag" a real bitfield with (using 1-bit struct
fields) is likely a better idea than using bool's there, and the code
for setting those options will have to be changed anyway...



reply via email to

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