Messages in this thread | | | Subject | Re: RFC: booleans and the kernel | From | Thomas Hood <> | Date | 25 Jan 2002 06:28:37 -0500 |
| |
Jeff Garzik wrote: > A small issue...
... bound therefore to generate the most discussion ...
> C99 introduced _Bool as a builtin type. The gcc patch for > it went into cvs around Dec 2000. Any objections to > propagating this type and usage of 'true' and 'false' around > the kernel?
What concerns me is the question of casting. Will truth always cast to integer value 1 and falsehood always cast to integer value 0, and vice versa? If so then the bool type is a lot like a "bit" type would be if C had one, i.e., a very short integer variable limited to the values 0 and 1. If the casts are not guaranteed then bool is a lot like an enumerated type where the compiler is free to choose whatever representations it wants for truth and falsehood.
I assume the casts are guaranteed. E.g., I take it that the result of a logical comparison is considered to be of type bool, but that the following will increment val by 1 if a > b val += (a > b)
In that case, perhaps it would be more perspicuous to define a "bit" type rather than a "bool" type, and to use 0 and 1 as its values rather than 'true' and 'false'. (A "bit" type would have all the advantages mentioned earlier by Peter Anvin http://marc.theaimsgroup.com/?l=linux-kernel&m=101191106124169&w=2 .)
-- Thomas Hood
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |