在 2026-3-6 17:45, Kirill Makurin 写道:
LIU Hao wrote:
But that's not standard behavior. I think we're too late for such changes; 
people who have been used to
the standard behavior would be annoyed.

Those %C and %S format specifiers are not part of standard C; they are however 
part of Single Unix Specification, and correspond to %lc and %ls respectively. 
IMO, there are zero reasons why anyone would use them in portable code since we 
have standardized %lc and %ls for this purpose.

Right, POSIX is also a standard, and for stdio functions it stays as an extension to ISO C. So standard `c`/`s` references a narrow character/string, and standard `C`/`S` references a wide character/string.


Microsoft's printf functions also support %C and %S with incompatible meaning.
See 
https://learn.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.

Standard-conforming code should never use %C and %S since this is undefined 
behavior, so I don't really see compatibility issues here. IMO, providing 
consistent Microsoft behavior among all CRTs is a compatibility improvement.

There's risk that someone has been abusing `%S` in `swprintf()` to incorporate a `char*` argument. This is quite arguable, but really they should use `%hs`.



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to