Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: PATCH change_specialist
Home

[Freeciv-Dev] Re: PATCH change_specialist

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: PATCH change_specialist
From: Stewart Adcock <stewart@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Dec 2001 13:24:17 -0800

Why not use the C99 boolean type when available (i.e. in gcc), which can be checked in the configure script, and default to int, or short, or something otherwise?

Maybe:
#if _USE_C99_SOURCE
typedef _Bool boolean;
#else
typedef short boolean;
#endif

Then the compiler will check it, when the feature is available.

Stewart.

Gregor Zeitlinger wrote:

On Mon, 17 Dec 2001, Raimar Falke wrote:

On Mon, Dec 17, 2001 at 03:13:48PM +0100, Gregor Zeitlinger wrote:

Whats wrong with TRUE and FALSE?

I just thought, if some parts of the code will be taken to Java, it makes
it easier, since Java has no preprocessor.

Can sed be used for this?

probably, but thats not a desirable way as it adds an extra unnecessary
step and reduces readablity.


+typedef int boolean;

A "can" or "is" in the function name is enough to indicate a boolean
return type.

it's more clear that way. It follows the approach to make code more
readable. Thus, boolean indicates that only true and false are allowed and
any assignment statement to a boolean variable should be that way.

However in C the compiler doesn't check it. So it IMHO equivalent to
write "return boolean" in a comment.

??? The C compiler treats it as an int, AFAIK.




--
____________________________________________________________________
Stewart Adcock   stewart@xxxxxxxxxxxxxxxx   www.stewart-adcock.co.uk
Dept. Chemistry & Biochemistry, University of California, San Diego
4234 Urey Hall, 9500 Gilman Drive, La Jolla, CA 92093-0365 USA
lab: +1 858 534 0956 home: +1 858 453 2577




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