I've ignored this error message forever: undeclared identifier 'bool'
and just lived with it, but, I was wondering why LccWin32 has no
'bool' type ?
Do you #include <stdbool.h> ?
Antoine
Yes, you have to include a file to use a basic type: bool.
The boolean type is called "_Bool" and you can use THAT type
WITHOUT including anything.
Please do not blame me. This is according to the C99 standard
that I implemented.
flames > /dev/C99StandardCommittee
> Yes, you have to include a file to use a basic type: bool.
>
> Please do not blame me. This is according to the C99 standard
> that I implemented.
Thanks Antoine and Jacob.
Jacob, no I don't blame you, I always just used BOOL.
Thought it was weird there was no 'bool' type, tho.
Guess I'll start including <stdbool.h> from now on.
In fact, there was a very good reason that the C99 committee didn't
make bool a keyword. There's a fair amount of existing C90 code
that uses bool as an identifier, and making it a keyword would have
broken all that code.
So they did the next best thing: they introduced a new keyword, _Bool,
which is in the reserved namespace (so any code it might break was
non-portable in the first place), and they added a macro definition for
"bool" in a new header. Existing C90 code that declares, for example:
typedef enum bool { false, true };
continues to work without change, and new code that uses the new
predefined type can easily do so by adding
#include <stdbool.h>
And yes, they did introduce some new keywords, namely restrict and
inline. But "restrict" was less likely to be used as an identifier,
and "inline" was used mostly as an extension with a meaning very
similar to what the C99 committee adopted.
(Conceivably they could have made it some kind of non-reserved
keyword, but getting all the corner cases right would have been a
daunting task.)
Certainly if C were being designed from scratch, it would make
sense for bool to be a keyword, just as int and char are keywords,
but the C99 committee didn't have the luxury of doing that.
(Bjarne Stroustrup, when he was designing "C with Classes", which
evolved into C++, decided he did have that luxury, which is why
bool is a keyword in C++.)
--
Keith Thompson (The_Other_Keith) ks...@mib.org <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"