Topic: Including headers from the standard header files
Author: phalpern@truffle.ultranet.com (Pablo Halpern)
Date: 1996/05/11 Raw View
Beman Dawes <beman@esva.net> wrote:
>Dietmar Kuehl wrote:
>> ... Would an
>> implementation including '<limits>' in '<bitset>' still be a conforming
>> implementation? ... or are the headers restricted to the headers listed.
>
>Right now you are not allowed to include additional headers. This causes
>the sort of problem you describe.
>
>The committee is actively working to resolve header inclusion policy
>issues, so expect some change at the Stockholm meeting in July.
Could someone educate us on the reason why the headers are restricted at
all? Why is it necessary for the *standard* to specify all of the
headers included in other headers? Couldn't this be "implementation
specified," instead?
Actually, as I read the HTML version of the April 1995 draft, it
indicates that a C++ header can include any other C++ header. It even
goes so far as to say that including a C++ header can include ALL of the
standard headers or just the one specified. The only restrictions I see
is that including certain standard headers MUST include certain other
standard headers but MAY include others and that including a standard
C++ header does not include any C headers. However, the C headers are
required to include a corresponding C++ header, so this is not really a
problem (in other words <limits.h> includes <limits>).
On a related point: are the standard headers required be defined so that
they can be included multiple times? In other words do they have to have
"#ifdef guards" that prevent their definitions from being included
twice? I couldn't find any language to this effect in the DWP.
-------------------------------------------------------------
Pablo Halpern phalpern@truffle.ultranet.com
I am self-employed. Therefore, my opinions *do* represent
those of my employer.
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: kuehl@horn.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: 1996/04/26 Raw View
Hi,
I have some problems understanding the rules on including header files
when implementing one of the standard header files: In 17.3.4.1
[lib.res.on.headers] it is stated that the headers listed in the
synopsis of the clause shall be included. This is no problem. But is
it also allowed to include additional headers? E.g. to figure out the
bits available in a word (say in an 'unsigned long') when implementing
the class 'bitset' it would be convenient to include '<limits>' and use
'numeric_limits' to figure out the number of bits. However, '<limits>'
is not listed in the synopsis part for '<bitset>'. Would an
implementation including '<limits>' in '<bitset>' still be a conforming
implementation? ... or are the headers restricted to the headers listed.
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl/
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Beman Dawes <beman@esva.net>
Date: 1996/04/29 Raw View
Dietmar Kuehl wrote:
> I have some problems understanding the rules on including header files
> when implementing one of the standard header files: In 17.3.4.1
> [lib.res.on.headers] it is stated that the headers listed in the
> synopsis of the clause shall be included. This is no problem. But is
> it also allowed to include additional headers? E.g. to figure out the
> bits available in a word (say in an 'unsigned long') when implementing
> the class 'bitset' it would be convenient to include '<limits>' and use
> 'numeric_limits' to figure out the number of bits. However, '<limits>'
> is not listed in the synopsis part for '<bitset>'. Would an
> implementation including '<limits>' in '<bitset>' still be a conforming
> implementation? ... or are the headers restricted to the headers listed.
Right now you are not allowed to include additional headers. This causes
the sort of problem you describe.
The committee is actively working to resolve header inclusion policy
issues, so expect some change at the Stockholm meeting in July.
--Beman Dawes (beman@esva.net)
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: "Bradd W. Szonye" <bradds@ix.netcom.com>
Date: 1996/05/01 Raw View
On Monday, April 29, 1996, Beman Dawes wrote...
> Dietmar Kuehl wrote:
> > I have some problems understanding the rules on including header files
> > when implementing one of the standard header files: In 17.3.4.1
> > [lib.res.on.headers] it is stated that the headers listed in the
> > synopsis of the clause shall be included. This is no problem. But is
> > it also allowed to include additional headers? E.g. to figure out the
> > bits available in a word (say in an 'unsigned long') when implementing
> > the class 'bitset' it would be convenient to include '<limits>' and use
> > 'numeric_limits' to figure out the number of bits. However, '<limits>'
> > is not listed in the synopsis part for '<bitset>'. Would an
> > implementation including '<limits>' in '<bitset>' still be a conforming
> > implementation? ... or are the headers restricted to the headers listed.
>
> Right now you are not allowed to include additional headers. This causes
> the sort of problem you describe.
>
> The committee is actively working to resolve header inclusion policy
> issues, so expect some change at the Stockholm meeting in July.
Well... there's a similar rule in C which says that standard headers
aren't allowed to include *any* other standard headers. I wasn't aware
that there was a similar (if less restrictive) rule in C++, but the same
workaround should apply.
The key is that you're not allowed to include another *standard* header.
However, the "trick" to managing common declarations in C standard headers
should apply for C++ as well:
(1) Create the object or type you want shared between headers with a
(nonstandard) name reserved to the implementation: typedef unsigned int
__size_t;
(2) Put the nonstandard declaration in an oddly-named (nonstandard)
header: <xxinternal.h>
(3) Include the nonstandard header in the standard header: #include
<xxinternal.h>
(4) Map the nonstandard "secret" name to the real name: typedef __size_t
size_t;
This implementation still conforms, and has the added advantage that if
the definition of size_t ever changes, source code changes are necessary
in only one header, <xxinternal.h>.
--
Bradd W. Szonye (bradds@ix.netcom.com), Doubleplus Corporation
"To chill or to pop a cap in my dome, whoomp, there it is."
-- Hamlet, Prince of Denmark
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]