'Does header file import modules a standard thing?

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


Solution 1:[1]

#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 imports 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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nicol Bolas