在 2025-10-21 16:41, Kirill Makurin 写道:
In this particular case it is quite unfortunate that (afaik) Windows is the only platform which cares about binary vs. non-binary I/O modes, but at the same time it does not implement standard way of doing this.
It's not just about the binary mode. On Linux, `freopen()` is the only way to change the orientation of a stream: After a narrow I/O function has been called on a stream, it makes the stream narrow-oriented, and further calls to wide functions on the same stream will fail; and after a wide I/O function has been called on a stream, it makes the stream wide-oriented, and further calls to narrow functions will fail. `freopen()` clears the orientation of a stream, to make it reusable.
It looks like Microsoft streams do not have orientation, and their `fwide()` 'doesn't conform to the C Standard.' [1]
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fwide?view=msvc-170
While it is good to be more conformant to ISO C, I believe it is better try to avoid situations when compiling the same code under MSVC and mingw-w64 will result in different behavior (unless it fixes an actual bug).I'm not sure about this either, I think I'd prefer keeping compatibility with MSVC if possible.
I think this makes sense, especially about UCRT. -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
