https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120160

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nshead at gcc dot gnu.org

--- Comment #3 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
(In reply to Jiang An from comment #1)
> `import std;` in every header looks too heavy to me. IMO it's undesired to
> import std::cin and its friends from <vector>.

FWIW, I'm not sure I necessarily agree: 'import std;' is effectively free (it
takes less than 0.01 seconds per TU on my machine) if '-fmodule-lazy' is in
effect, as it is by default.  Yes, it's potentially a bit surprising for other
names to be exported as well, but that is already the case to a lesser or
greater extent due to the nature of the headers.

(In reply to m.cencora from comment #2)
> I think better option for aiding migration to modules world is to provide
> something similar to MSVC /translateIncludes option as that would work in
> case of all code, and not just standard library headers.
> 
> https://learn.microsoft.com/en-us/cpp/build/reference/
> translateinclude?view=msvc-170

GCC always performs automatic include translation for header units, if the
module mapper provides an eligible CMI (and doesn't disable the mapping).  You
can use
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-flang-info-include-translate
to get the compiler to dump a note every time it does this.

One downside of this is that this will likely not be as performant for standard
library headers as replacing with 'import std', as depending on how the
standard library header CMIs are built the compiler will probably have to do a
fair amount of name deduplication anyway, which is relatively expensive.  It's
definitely better than nothing though!

Reply via email to