This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

### 2428. "External declaration" used without being defined

Section: 16.4.3.2 [using.headers] Status: C++17 Submitter: Tim Song Opened: 2014-09-03 Last modified: 2017-07-30

Priority: 0

View all other issues in [using.headers].

View all issues with C++17 status.

Discussion:

16.4.3.2 [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." (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 16.4.3.2 [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]

Proposed resolution:

This wording is relative to N3936.

1. Edit 16.4.3.2 [using.headers] as indicated:

   > A translation unit shall include a header only outside of any external declaration 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.