There's a way to conditionaly use import statements with the C 20 modules feature?
// Pseudocode
IF OS == WINDOWS:
import std.io;
ELSE:
import <iostream>;
CodePudding user response:
You use macros, just like you would for most other conditional compilation operations. And yes, this means that modules have to be built differently for different command line options. But that was always going to be the case.
Also FYI: std.io
is a thing provided by MSVC, not Windows. And you should avoid using it due to its non-standard (and likely not-going-to-be-standard) status. If you must use one of MSVC's standard library modules, use import std;
.