[email protected] wrote:
> This patch defines:
> * a generic boolean-type, named "bool"
> * aliases to 0 and 1, named "false" and "true"
>
> Signed-off-by: Richard Knutsson <[email protected]>
Shouldn't this simply use _Bool?
-hpa
Citerar "H. Peter Anvin" <[email protected]>:
> [email protected] wrote:
> > This patch defines:
> > * a generic boolean-type, named "bool"
> > * aliases to 0 and 1, named "false" and "true"
> >
> > Signed-off-by: Richard Knutsson <[email protected]>
>
> Shouldn't this simply use _Bool?
Well, it is (now) just a typedef of it. :)
But I find it better, both because it is more similar to the common types:
short, lowlettered words. But also because most editors with highlightning
recognize "bool", but not "_Bool", as a type (as I found it).
> -hpa
/Richard Knutsson
[email protected] wrote:
> Citerar "H. Peter Anvin" <[email protected]>:
>
>> [email protected] wrote:
>>> This patch defines:
>>> * a generic boolean-type, named "bool"
>>> * aliases to 0 and 1, named "false" and "true"
>>>
>>> Signed-off-by: Richard Knutsson <[email protected]>
>> Shouldn't this simply use _Bool?
>
> Well, it is (now) just a typedef of it. :)
>
> But I find it better, both because it is more similar to the common types:
> short, lowlettered words. But also because most editors with highlightning
> recognize "bool", but not "_Bool", as a type (as I found it).
>
<stdbool.h> should include:
typedef _Bool bool;
#define true 1
#define false 0
There is no enum involved.
-hpa
H. Peter Anvin wrote:
> [email protected] wrote:
>> This patch defines:
>> * a generic boolean-type, named "bool"
>> * aliases to 0 and 1, named "false" and "true"
>>
>> Signed-off-by: Richard Knutsson <[email protected]>
>
> Shouldn't this simply use _Bool?
No sane person should use "_Bool" in real code. Unnecessary StudlyCaps
and unnecessary underscore.
"bool" is far easier to type, and looks less weird.
Jeff
H. Peter Anvin wrote:
> There is no enum involved.
There should be. It makes more information available to the C compiler,
and it makes useful symbols available to the debugger.
Jeff
Jeff Garzik wrote:
> H. Peter Anvin wrote:
>> [email protected] wrote:
>>> This patch defines:
>>> * a generic boolean-type, named "bool"
>>> * aliases to 0 and 1, named "false" and "true"
>>>
>>> Signed-off-by: Richard Knutsson <[email protected]>
>>
>> Shouldn't this simply use _Bool?
>
> No sane person should use "_Bool" in real code. Unnecessary StudlyCaps
> and unnecessary underscore.
>
> "bool" is far easier to type, and looks less weird.
>
That wasn't the point. The point was that bool should be a typedef to
_Bool instead of an enum.
-hpa
Jeff Garzik wrote:
> H. Peter Anvin wrote:
>> There is no enum involved.
>
> There should be. It makes more information available to the C compiler,
> and it makes useful symbols available to the debugger.
>
_Bool is a native C type; it has all the information the C compiler needs.
-hpa
H. Peter Anvin wrote:
> That wasn't the point. The point was that bool should be a typedef to
> _Bool instead of an enum.
Quoting from the patch to which you are replying:
+typedef _Bool bool;
'enum' is only used for defining 'true' and 'false'.
Jeff
H. Peter Anvin wrote:
> Jeff Garzik wrote:
>> H. Peter Anvin wrote:
>>> There is no enum involved.
>> There should be. It makes more information available to the C
>> compiler, and it makes useful symbols available to the debugger.
> _Bool is a native C type; it has all the information the C compiler needs.
"#define true 1" however does not.
Jeff
Jeff Garzik wrote:
> H. Peter Anvin wrote:
>> Jeff Garzik wrote:
>>> H. Peter Anvin wrote:
>>>> There is no enum involved.
>
>>> There should be. It makes more information available to the C
>>> compiler, and it makes useful symbols available to the debugger.
>
>> _Bool is a native C type; it has all the information the C compiler
>> needs.
>
> "#define true 1" however does not.
>
I guess that's fair, although when you put it into a type _Bool they're
going to devolve to pure constants.
-hpa