including standard library headers in the purview of a module

63 views
Skip to first unread message

Richard Smith

unread,
Oct 22, 2018, 8:01:14 PM10/22/18
to mod...@isocpp.org
Consider code such as:

module M;
#include <vector>

I do not believe we want to allow this. However, we don't have an explicit prohibition on it, and [using.headers] would currently tend to suggest that it's valid and works.

I suggest we add a rule such as:

[using.headers]/3:

"A translation unit shall include a header only outside of any declaration or definition <ins>or the purview of any named module</ins>, 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."

Does that seem OK?

Gabriel Dos Reis

unread,
Oct 22, 2018, 8:08:09 PM10/22/18
to mod...@isocpp.org

I can see that for standard headers, but I think it is too restricive for all #include directives.

 

--
You received this message because you are subscribed to the Google Groups "SG2 - Modules" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modules+u...@isocpp.org.
To post to this group, send email to mod...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/modules/.

Richard Smith

unread,
Oct 22, 2018, 8:13:18 PM10/22/18
to mod...@isocpp.org
This part of the standard wording uses the term "header" to refer specifically and only to the C++ standard library headers. (See the implicit definition of the term "header" in [headers]/1.)

I also think that permitting other #includes in the purview of a module should be permitted (for the cases where you really want the "drop a bunch of tokens here" interpretation), so I think we agree on all counts.

Gabriel Dos Reis

unread,
Oct 22, 2018, 8:21:48 PM10/22/18
to mod...@isocpp.org

Violent agreement.

Reply all
Reply to author
Forward
0 new messages