Hello everyone,
I encountered this issue and suggest the following ideas.
[...]
In C++23, import std was introduced to facilitate the use of standard libraries.
However, it does not expose macros, so a user have to include the corresponding header files again, for example:
#include <cstdio> // for stderr
[...]
To resolve other C streams macros, I propose global variables, std::in, std::out, and std::err as substitutes for stdin, stdout, and stderr, respectively.
Rather than coming up with a different ad-hoc solution for each macro in the Standard Library (assert, offsetof, stdin,...), we should be looking for a solution that Just Works for all macros. "Just keep using #include" is the most obvious solution; but maybe someone can find another. I don't think a shotgun approach of ad-hoc solutions is the right way to go, at all.
(I'd had a vague idea that this was the problem that `import std.compat;` was intended to solve; but no, that just puts entities into the global namespace in addition to `std`. It doesn't do anything about macros.)
The same question was asked on StackOverflow last January. No answers yet, except for the obvious one of "just keep using #include":
("Just keep using #include" is not a bad idea, btw. It's certainly what I recommend for production codebases, now and for the foreseeable future.)
my $.02,
–Arthur