Section: 18.104.22.168 [using.headers] Status: C++17 Submitter: Tim Song Opened: 2014-09-03 Last modified: 2017-07-30 20:15:43 UTC
View all other issues in [using.headers].
View all issues with C++17 status.
22.214.171.124 [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 126.96.36.199, 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." (6.6 [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 188.8.131.52 [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.
[Urbana 2014-11-07: Move to Ready]
This wording is relative to N3936.
Edit 184.108.40.206 [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.