On Sun, Feb 18, 2024 at 12:38 PM SM via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
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.
The following papers try to solve the similar macro issues:
1. P2654 Macros And Standard Library Modules - import should suffice
2. P2884 assert Should Be A Keyword In C++26 - Supporting standard C++23 macros in module std
3. P2883 offsetof Should Be A Keyword In C++26 - Supporting standard C++23 macros in module std

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":
https://stackoverflow.com/questions/75041883/how-to-use-standard-library-macros-with-std-module-in-c23

("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