Created on 2014-09-03.00:00:00 last changed 90 months ago
Proposed resolution:
This wording is relative to N3936.
Edit [using.headers] as indicated:
A translation unit shall include a header only outside of any
externaldeclaration or definition, and shall include the header lexically before the first reference in that translation unit to any of the entities declared in that header. No diagnostic is required.
[ Urbana 2014-11-07: Move to Ready ]
[using.headers]/3 says
A translation unit shall include a header only outside of any external declaration or definition […]
This wording appears to be borrowed from the C standard. However, the term "external declaration" is not defined in the C++ standard, and in fact is only used here as far as I can tell, so it is unclear what it means. The C standard does define external declarations as (WG14 N1570 6.9 External definitions/4-5):
As discussed in 5.1.1.1, the unit of program text after preprocessing is a translation unit, which consists of a sequence of external declarations. These are described as "external" because they appear outside any function (and hence have file scope). [...] An external definition is an external declaration that is also a definition of a function (other than an inline definition) or an object.
The corresponding description of a translation unit in C++ is "A translation unit consists of a sequence of declarations." ([basic.link]/3).
So it appears that the C++ counterpart of "external declaration" in C is simply a "declaration" at file scope. There is no need to specifically limit the statement in [using.headers]/3 to file-scope declarations, however, since every non-file-scope declaration is necessarily inside a file-scope declaration, so banning including a header inside file-scope declarations necessarily bans including one inside non-file-scope declarations as well.History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2015-05-22 18:31:21 | admin | set | status: ready -> wp |
2014-11-08 16:43:57 | admin | set | messages: + msg7179 |
2014-11-08 16:43:57 | admin | set | status: new -> ready |
2014-10-06 20:18:00 | admin | set | messages: + msg7117 |
2014-09-03 00:00:00 | admin | create |