C++ 20 modules guaranteed backward compatible so modules can import headers.
And Visual Studio introduced header file import modules,is this stardard or just a VS thing?
// MyProgram.h
import std.core;
#ifdef DEBUG_LOGGING
import std.filesystem;
#endif
#include
is a preprocessor directive that does a textual copy-and-paste of the text in the target file. Modules didn't change this. Textually copy-and-pasting import
directives is still textual copy-and-pasting.
So yes, this is standard. Assuming your compiler implements them correctly.
That being said, it's probably not a good idea to have headers import
things. If you want to build a collection of import
s used by various files in your system, just build a proper named module and reap the benefits of the module build system. It's OK to export import
modules.