Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [RFC] x & (1u << y)
Home

[Freeciv-Dev] Re: [RFC] x & (1u << y)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [RFC] x & (1u << y)
From: Petrus Viljoen <viljoenp@xxxxxxxxxxx>
Date: Wed, 13 Feb 2002 12:04:59 +0200

Raimar Falke wrote:

> There are a lot of constructs like "x & (1u << y)" in the code:
>  - city options, flags and roles
>  - shared vision
>  - embassy
>  - claims
>  - gotohand
>  - known and sent in maphand
>
> These all are used as a bool but aren't a bool. Should they be wrapped
> with BOOL_VAL, a new test_bit or with functions specific to the
> domains above?
>
>         Raimar

Why not change the flags to structs  like

struct foo {
    int can_build_t1 : 1;        /* This is a one bit int (0 | 1) */
    int can_build_t2 : 1;
    ....
    }

then you can use .

if (foo_var.can_build_t1 == TRUE) ....

etc..

It should make code more readable than  "x & (1u << y)"

???




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