Re: short circuit evaluation
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 17 Sep 2008 20:51:26 -0700
CBFalconer <cbfalconer@xxxxxxxxx> writes:
Keith Thompson wrote:
CBFalconer <cbfalconer@xxxxxxxxx> writes:
James Kuyper wrote:
... snip about <stdbool.h> ...
You're right - my mistake. But I mis-remembered it as a standard
typedef because it makes more sense to me that it would be a
typedef. Does anyone know why it's a macro? I suppose it might be
because you can #undef a macro, but you can't turn off a typedef.
If you want to use 'bool' as the standard macro in one part of a
translation unit, and as a user-defined identifier with an
incompatible meaning from legacy code in a later part of the same
translation unit, making 'bool' a macro allows you do so. But
that seems like too convoluted a motivation for such a choice.
Because 'bool' was not a reserved word in C90. This way you can
keep the compiler compatible with C90 source that used it, and true
and false macros, differently. Note that _Bool IS a reserved word,
but is in the implementors namespace.
The question is why 'bool' is a macro rather than a typedef, not why
it's not a keyword in C99.
Which is what I thought I said.
Um, no.
Your statement "Because 'bool' was not a reserved word in C90" is a
valid answer to "Why is 'bool' not a reserved word in C99?", but
nobody asked that question.
*Either* making bool a macro *or* making it a typedef would avoid any
problems with C90 code that uses the name "bool" as an identifier;
such code wouldn't include <stdbool.h>, so the macro or typedef would
not be visible.
The question under discussion was: Why is bool a macro rather than a
typedef in C99? Nothing you've said addresses that question.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- short circuit evaluation
- From: Lassie
- Re: short circuit evaluation
- From: sh . vipin
- Re: short circuit evaluation
- From: jameskuyper
- Re: short circuit evaluation
- From: vippstar
- Re: short circuit evaluation
- From: James Kuyper
- Re: short circuit evaluation
- From: CBFalconer
- Re: short circuit evaluation
- From: Keith Thompson
- Re: short circuit evaluation
- From: CBFalconer
- short circuit evaluation
- Prev by Date: Re: Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]
- Next by Date: Re: Any way to take a word as input from stdin ?
- Previous by thread: Re: short circuit evaluation
- Next by thread: Re: short circuit evaluation
- Index(es):
Relevant Pages
|