Re: Including headers "within a definition"
On 20 Feb., 19:06, gennaro.pr...@yahoo.com (Gennaro Prota) wrote:
I'm perplexed by this requirement in the current standard draft:
17.4.2.1 [using.headers] A translation unit shall include a header
only outside of any external declaration of definition [...]
Logically speaking, declarations and definitions are recognized much
later than #include directives, so how can one say whether the include
directive is within a definition?
Just a guess: This rule exists to forbid something like this:
1) Inside definition:
struct curious {
#include <utility>
std::pair<int, double> m;
};
2) Inside declaration:
void foo(
#include <utility>
std::pair<int, double> arg);
Note too, that the wording employs a "shall" but not "no diagnostic is
required".
Two weeks ago I have learned that "shall" usually implies that any
violation would require a diagnostics - despite those cases, where
the standard explicitely says otherwise and some other
exceptions ;-).
This seems to be something like a metastandard (to use James Kanze's
words). See the thread
"detecting, at compile-time, whether a type is complete"
started at Jan. 30th, 10:38. Here James' reply to my question:
http://tinyurl.com/yw2vlh
Grettings from Bremen,
Daniel
---
[ 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.comeaucomputing.com/csc/faq.html ]