Topic: -1?Q? 16.2 Source file inclusion 2
Author: stephen.clamage@sun.com (Steve Clamage)
Date: Mon, 14 Jun 2004 17:52:43 +0000 (UTC) Raw View
Steven T. Hatton wrote:
> What exactly does the following mean?
>=20
> ISO/IEC 14882:2003(E)
> =A716.2 Source file inclusion=20
> ...
> =B62 "A preprocessing directive of the form
> # include <h-char-sequence> new-line
> searches a sequence of implementation-defined places for a header ident=
ified
> uniquely by the specified sequence between the < and > delimiters, and
> *causes* the *replacement* of that directive by the *entire* *contents*
> of the *header*."
>=20
> I am specifically interested in what is meant by "the entire contents o=
f the
> header". I understand the header need not be a traditional header file=
, or
> even a file. But, for the sake of clarification, suppose the header in
> question is an actual file. Would the requirement be fulfilled if the
> declarations of all entities required by the Standard to be "in the hea=
der"
> were present and the actual implementations were available to the linke=
r?=20
The standard is attempting to describe the *effect* of an include=20
directive, without specifying a method for accomplishing that effect.=20
In particular, after (but not before) including the header, the=20
declarations the header is required to provide are present in the program.
For example, if you do not include <stdio.h> or <cstdio>, the=20
identifer FILE is not known to the compiler. But upon including one of=20
those headers, FILE aquires its standard declaration as a type.
In the usual implementation, the headers are actual files consisting=20
of C++ source code text. In such an implementation, the entire source=20
code line of the #include directive is conceptually replaced by the=20
entire contents of the header file. Usually the compiler discards the=20
#include line after interpreting it, then switches its input to the=20
referenced header file, switching back to the original file after the=20
entire header has been read.
But C++ implementations are allowed to use any sort of magic, as long=20
as the equivalent result is obtained. For example, the compiler could=20
know the contents of the standard headers, and when it sees, for=20
example, #include <map>, enable the declarations of everything the=20
<map> header is supposed to declare. No <map> source file need be=20
involved.
If compilation and linking are separate and sequential steps (as in=20
the usual implementation, but not required by the standard), I don't=20
see how the linker knowing about headers would be useful. But nothing=20
in the standard says *how* the transformation of source code to a=20
running program is to be accomplished. It prescribes only the net effect.
---
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: hattons@globalsymmetry.com ("Steven T. Hatton")
Date: Fri, 11 Jun 2004 16:07:58 +0000 (UTC) Raw View
What exactly does the following mean?
ISO/IEC 14882:2003(E)
=A716.2 Source file inclusion=20
...
=B62 "A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identif=
ied
uniquely by the specified sequence between the < and > delimiters, and
*causes* the *replacement* of that directive by the *entire* *contents*
of the *header*."
I am specifically interested in what is meant by "the entire contents of =
the
header". I understand the header need not be a traditional header file, =
or
even a file. But, for the sake of clarification, suppose the header in
question is an actual file. Would the requirement be fulfilled if the
declarations of all entities required by the Standard to be "in the heade=
r"
were present and the actual implementations were available to the linker?=
=20
I suspect the use of templates will complicate this matter.
(I will observe for the sake of the record that the title of the section =
is
"_Source_file_ inclusion")
--=20
STH
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]