* relationship between standard C and gcc compiler suite?
@ 2005-08-03 13:47 Robert P. J. Day
2005-08-03 17:12 ` Steve Graegert
2005-08-04 11:06 ` Glynn Clements
0 siblings, 2 replies; 5+ messages in thread
From: Robert P. J. Day @ 2005-08-03 13:47 UTC (permalink / raw)
To: C programming list
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.
rday
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: relationship between standard C and gcc compiler suite?
2005-08-03 13:47 relationship between standard C and gcc compiler suite? Robert P. J. Day
@ 2005-08-03 17:12 ` Steve Graegert
2005-08-03 17:22 ` Robert P. J. Day
2005-08-04 11:06 ` Glynn Clements
1 sibling, 1 reply; 5+ messages in thread
From: Steve Graegert @ 2005-08-03 17:12 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: C programming list
On 8/3/05, Robert P. J. Day <rpjday@mindspring.com> 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 <graegerts@gmail.com>
Software Consultancy {C/C++ && Java && .NET}
Mobile: +49 (176) 21248869
Office: +49 (9131) 7126409
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: relationship between standard C and gcc compiler suite?
2005-08-03 17:12 ` Steve Graegert
@ 2005-08-03 17:22 ` Robert P. J. Day
2005-08-03 17:31 ` Steve Graegert
0 siblings, 1 reply; 5+ messages in thread
From: Robert P. J. Day @ 2005-08-03 17:22 UTC (permalink / raw)
To: Steve Graegert; +Cc: C programming list
On Wed, 3 Aug 2005, Steve Graegert wrote:
> 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.
ok, this is where i might be having my difficulty. in H&S (5th ed),
p. 325, i read (emphasis added):
"Certain Standard C libraries can be considered part of the language.
The provide standard definitions and parameterization that help make C
programs more portable... These core libraries consist of the header
files ... stdbool.h, ..."
my reading of this is that stdbool.h is not an extension, it's a part
of the core. what am i mnisreading here?
rday
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: relationship between standard C and gcc compiler suite?
2005-08-03 17:22 ` Robert P. J. Day
@ 2005-08-03 17:31 ` Steve Graegert
0 siblings, 0 replies; 5+ messages in thread
From: Steve Graegert @ 2005-08-03 17:31 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: C programming list
On 8/3/05, Robert P. J. Day <rpjday@mindspring.com> wrote:
> On Wed, 3 Aug 2005, Steve Graegert wrote:
>
> > 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.
>
> ok, this is where i might be having my difficulty. in H&S (5th ed),
> p. 325, i read (emphasis added):
>
> "Certain Standard C libraries can be considered part of the language.
> The provide standard definitions and parameterization that help make C
> programs more portable... These core libraries consist of the header
> files ... stdbool.h, ..."
>
> my reading of this is that stdbool.h is not an extension, it's a part
> of the core. what am i mnisreading here?
It is not an extension to the standard, namely C99, but an extension
of GCC in order to allow native C code to be compiled as C++ in a
clean way. So you're reading was absolutely correct. Almost every
vendor ships with <stdbool.h>, sometimes it is placed in the include
directory for the compiler (on Linux/GNU systems at least), but HP,
for example, puts it in /usr/include. It's just a Linux thing to put
it elsewhere.
Regards
\Steve
--
Steve Graegert <graegerts@gmail.com>
Software Consultancy {C/C++ && Java && .NET}
Mobile: +49 (176) 21248869
Office: +49 (9131) 7126409
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: relationship between standard C and gcc compiler suite?
2005-08-03 13:47 relationship between standard C and gcc compiler suite? Robert P. J. Day
2005-08-03 17:12 ` Steve Graegert
@ 2005-08-04 11:06 ` Glynn Clements
1 sibling, 0 replies; 5+ messages in thread
From: Glynn Clements @ 2005-08-04 11:06 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: C programming list
Robert P. J. Day 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.
The rationale is essentially making things work on systems where the
system's libc isn't GNU libc.
If a header is in gcc's private include directory, it usually
indicates that the OS installs its own copy of the header in
/usr/include, but that header won't work with gcc. gcc searches its
private include directory before /usr/include, so gcc-specific headers
override the system's versions.
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-08-04 11:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-03 13:47 relationship between standard C and gcc compiler suite? Robert P. J. Day
2005-08-03 17:12 ` Steve Graegert
2005-08-03 17:22 ` Robert P. J. Day
2005-08-03 17:31 ` Steve Graegert
2005-08-04 11:06 ` Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).