Title
"External declaration" used without being defined
Status
c++17
Section
[using.headers]
Submitter
Tim Song

Created on 2014-09-03.00:00:00 last changed 82 months ago

Messages

Date: 2014-11-08.16:43:57

Proposed resolution:

This wording is relative to N3936.

  1. Edit [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.

Date: 2014-11-08.16:43:57

[ Urbana 2014-11-07: Move to Ready ]

Date: 2014-09-03.00:00:00

[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:43adminsetstatus: wp -> c++17
2015-05-22 18:31:21adminsetstatus: ready -> wp
2014-11-08 16:43:57adminsetmessages: + msg7179
2014-11-08 16:43:57adminsetstatus: new -> ready
2014-10-06 20:18:00adminsetmessages: + msg7117
2014-09-03 00:00:00admincreate