On 8/3/05, Robert P. J. Day <[EMAIL PROTECTED]> wrote:
>
> according to my 5th ed. of H&S, C99 introduced the unsigned integer
> type "_Bool" and refers to the corresponding header file stdbool.h.
> but on my linux system, that header file is not in the standard
> /usr/include directory, where i would have expected it.
>
> rather, it's included with gcc-4.0.1, and it's in this directory:
>
> /usr/lib/gcc/i386-redhat-linux/4.0.1/include
>
> i'm sure the end result is the same in that i can just
>
> #include <stdbool.h>
>
> but is there some kind of overall rationale as to what "standard"
> header files would actually be supplied by gcc itself? just trying to
> figure out the pattern here. obviously, this question generalizes to
> more than just asking about the boolean file.
Since C++ provides bool as a true boolean type <stdbool.h> is provided
to allow C code being compiled as C++ and to prevent name clashes.
Some C programs #define "bool" and/or "true" and "false" possibly
causing compatibility problems when compiled as C++.
In case of GCC, including <stdbool.h> cleans up #defines and allows
C++ compilation. It is therefore recommended to #define these
identifiers only when _needed_ and after including <stdbool.h>.
<stdbool.h> is provided as an extension and, for this reason, not
placed into the include directory of the C standard library.
Regards
\Steve
--
Steve Graegert <[EMAIL PROTECTED]>
Software Consultancy {C/C++ && Java && .NET}
Mobile: +49 (176) 21248869
Office: +49 (9131) 7126409
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming"
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html