在 2026-3-18 19:29, Kirill Makurin 写道:
2. L"%S" — second 3. L"%hs" — thirdThis is only valid with Microsoft's `wprintf`; this won't work for `char *` even with meaning from Sigle Unix Specification. Microsoft's %C and %S use wideness opposite to that of function called - %S for `printf` is `wchar_t *` while %S for `wprintf` is `char *`.In Single Unix Specification, %S is always equivalent to %ls and %C is always equivalent to %lc. Also, %hs is not standard nor POSIX.
Yes, that's exactly the origination of my concern -- there may be code that passes `%s` to `swprintf()` for a `const char*` argument.
I don't get it. Why would anyone ever try to use %ls to pass `char *` to either `printf` or `wprintf`? Standard is clear about %ls - it is always a wide character string.
It may be a result of macro expansion like this:
LPCTSTR name = ...;
int index = ...;
TCHAR key[64];
_stprintf(key, _T("%s%d"), name, index);
--
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
