Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2461) bool type already exists
Home

[Freeciv-Dev] (PR#2461) bool type already exists

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2461) bool type already exists
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 1 Dec 2002 00:19:43 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Someone was trying to compile freeciv-test (SDL client) on a BeOS
variant.  They got the following error:

<[Be]rnd>  gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl    -g -Wall
-Wno-multichar -c `test -f 'connection.c' || echo './'`connection.c
<[Be]rnd>  In file included from
/boot/develop/headers/be/kernel/OS.h:15,
<[Be]rnd>                   from
/boot/develop/headers/be/bone/netinet/in.h:49,
<[Be]rnd>                   from
/boot/home/Entwicklung/Sourcecodes/freeCIV_SDL/freeciv-test/common/netintf.h:38,
<[Be]rnd>                   from
/boot/home/Entwicklung/Sourcecodes/freeCIV_SDL/freeciv-test/common/connection.c:43:
<[Be]rnd>  /boot/develop/headers/posix/be_prim.h:73: error: conflicting
types for `bool'
<[Be]rnd> 
/boot/home/Entwicklung/Sourcecodes/freeCIV_SDL/freeciv-test/common/shared.h:44: 
error: previous declaration of `bool'
<[Be]rnd>  make[2]: *** [connection.o] Error 1
<[Be]rnd>  make[2]: Leaving directory
`/boot/home/Entwicklung/Sourcecodes/freeCIV_SDL/freeciv-test/common'
<[Be]rnd>  make[1]: *** [all-recursive] Error 1
<[Be]rnd>  make[1]: Leaving directory
`/boot/home/Entwicklung/Sourcecodes/freeCIV_SDL/freeciv-test'
<[Be]rnd>  make: *** [all] Error 2
<[Be]rnd>  $ 

Indicating that 'bool' was already defined in the system headers.  It is
typedefed as unsigned char.

I see two choices:

- Use fc_bool instead of bool.  That way we don't interfere with anyone
else.  But people will forget to use it.  And IMO it is less readable.

- Check for the 'bool' type in configure, and define HAVE_BOOL based on
this.  The downside here is that the check may not be trivial, since we
don't know what header it might be in.

I much prefer the second solution.

There may be a problem with TRUE and FALSE as well (although not in this
case, apparently).  It might be productive to use

  #define TRUE ((bool)1)
  #define FALSE ((bool)0)

to help in type checking.  Or, perhaps this will just give spurious
problems...

jason




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