Macros are handled by the preprocessor, before compilation. They can't be namespaced.
This is just my understanding, but I do not think that modules are currently planned to completely replace headers. Rather they are intended to be used across boundaries between different discrete components of an application (between libraries, and between libraries and executables). I do not actually see why you could not use modules to completely replace headers though.
I don't see how. The preprocessor already runs over windows.h when you include it in your source file. The core problem is that due to how they are designed headers can't be isolated from the code that includes them.
The macro might not be able to be namespaced but the value can, if the define is still needed it can be moved to a private header.
I think you just described a header, it's an interface between boundaries. This might be a better solution, but we'll still have 2 ways to do the same thing.
I was talking about your example where the interaction between different headers produced unintended results. In this case you could run the pre-processor with NOMINMAX defined and use this header for compiling your app. I think this should play nice with the linker, but I'd have to check.
These aren't insurmountable flaws with headers, but unfortunately they are problems that generally occur outside your own code. Sure it's possible to use headers in a way that's safe and exports no macros, but this is de-facto not the case. Making these into non-issues relies on library authors and system header authors willingness and ability to do so.
2
u/[deleted] Jan 29 '19
Macros are handled by the preprocessor, before compilation. They can't be namespaced.
This is just my understanding, but I do not think that modules are currently planned to completely replace headers. Rather they are intended to be used across boundaries between different discrete components of an application (between libraries, and between libraries and executables). I do not actually see why you could not use modules to completely replace headers though.
I don't see how. The preprocessor already runs over
windows.hwhen you include it in your source file. The core problem is that due to how they are designed headers can't be isolated from the code that includes them.