seeplus wrote: |
---|
Note that #pragma weak isn't supported by VS |
IIRC "#pragma
anything" is gonna be defacto non-standard, no matter what. What works with one compiler suite is not guaranteed to work with others.
A semi-exception to that is
#pragma once
. Still not recognized by all compilers AFAIK, though.
There seem to be more than a few people who want to make
#pragma once
be added to the C++ standard, in part to get away from verbose
#ifndef/#define/#endif
header guards.
With modules that becomes a (somewhat) moot point, there is no need to worry about inadvertent multiple imports.
In my admittedly limited experience using modules, with VS 2019/2022*, a module interface file (.cppm) can import a C++ library, say
import <random>;
. Import that interface file into a translation unit that uses the <random> library and that translation unit needs to also
import <random>;
or compilation fails.
Modules are not header files in my experience. At least not with VS. *shrug*
*AFAIK there is no definitive standard for the file extension of module interface files yet, I've seen .cppm commonly used. MS (and VS) want to use .ixx. *Blech*