[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.61.0608231403280.14327@yvahk01.tjqt.qr>
Date: Wed, 23 Aug 2006 14:06:10 +0200 (MEST)
From: Jan Engelhardt <jengelh@...ux01.gwdg.de>
To: Richard Knutsson <ricknu-0@...dent.ltu.se>
cc: Andrew Morton <akpm@...l.org>,
Prajakta Gudadhe <pgudadhe@...dia.com>, jeff@...zik.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2.6.18-rc4-mm2] Generic boolean (was: Re: Generic booleans
in -mm)
Hi,
> There has been concern about adding other values then 0 and 1. There has been
> ideas to do something like:
> bool b = i & 1 : 0;
I think you miseed a '?'
bool b = (i & 1) ? : 0;
> /*or*/
> bool b = !!i;
>
> but all that is needed is just a casting:
>
> bool b = (bool) i;
No casting needed (in fact, casting is more evil than !!). If bool is a
bool, then the compiler will (hopefully) ensure that b will only get
values valid for bools.
$ cat x.c
#include <stdbool.h>
#include <stdio.h>
int main(int argc, const char **argv) {
_Bool b = argc;
printf("%d\n", (int)b);
return 0;
}
$ ./a.out
1
Jan Engelhardt
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists