Date: Mon, 19 Feb 2024 02:38:15 +0900
Hello everyone,
I encountered this issue and suggest the following ideas.
Please, read this email with a grain of salt because I am not a
professional C++ programmer.
In addition, English is my second language, so I apologize for any errors.
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
// alternatively
// import <cstdio>;
import std;
int main()
{
std::println(stderr, "error message");
}
One approach to address this issue could be to offer another api,
std::eprint.
std::print uses stdout by default so it would be reasonable for std::eprint
to use stderr.
cf) std::println(std::cerr, "error message") is also available.
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.
I am afraid that there would be any naming conflicts and potential
problems, or these variables are reserved for future usage.
The following papers try to solve the similar macro issues:
1. Macros And Standard Library Modules - import should suffice
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2654r0.pdf
2. assert Should Be A Keyword In C++26 - Supporting standard C++23 macros
in module std
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2884r0.pdf
3. offsetof Should Be A Keyword In C++26 - Supporting standard C++23 macros
in module std
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2883r0.pdf
I appreciate your time and attention in reviewing this email.
Best regards,
SM
I encountered this issue and suggest the following ideas.
Please, read this email with a grain of salt because I am not a
professional C++ programmer.
In addition, English is my second language, so I apologize for any errors.
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
// alternatively
// import <cstdio>;
import std;
int main()
{
std::println(stderr, "error message");
}
One approach to address this issue could be to offer another api,
std::eprint.
std::print uses stdout by default so it would be reasonable for std::eprint
to use stderr.
cf) std::println(std::cerr, "error message") is also available.
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.
I am afraid that there would be any naming conflicts and potential
problems, or these variables are reserved for future usage.
The following papers try to solve the similar macro issues:
1. Macros And Standard Library Modules - import should suffice
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2654r0.pdf
2. assert Should Be A Keyword In C++26 - Supporting standard C++23 macros
in module std
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2884r0.pdf
3. offsetof Should Be A Keyword In C++26 - Supporting standard C++23 macros
in module std
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2883r0.pdf
I appreciate your time and attention in reviewing this email.
Best regards,
SM
Received on 2024-02-18 17:38:52