Re: short circuit evaluation
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Wed, 17 Sep 2008 21:33:40 -0400
James Kuyper wrote:
CBFalconer wrote:
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.
How would making bool a typedef that is defined in stdbool.h cause a
problem for the compiler? Standard typedefs (like size_t) aren't
keywords, any more than standard macros are.
Consider a source for C90 that defines bool, true, and false. If
C99 made those words reserved, the C90 source could not be compiled
on a C99 compiler (barring identical definitions). However, simply
failing to #include <stdbool.h> avoids the whole problem. This is
fairly automatic, since <stdbool.h> didn't exist in C90.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
.
- Follow-Ups:
- Re: short circuit evaluation
- From: James Kuyper
- Re: short circuit evaluation
- 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: James Kuyper
- short circuit evaluation
- Prev by Date: Re: short circuit evaluation
- Next by Date: Re: Question about void pointers
- Previous by thread: Re: short circuit evaluation
- Next by thread: Re: short circuit evaluation
- Index(es):
Relevant Pages
|