On Tue, 21 Aug 2018, Martin Sebor wrote: > I still believe it would be simpler, more robust, and safe > to pass in a flag to either count bytes (the default, for > all callers except sprintf %ls), or elements of the string > type (for sprintf %ls).
But the correct thing to count for sprintf %ls is elements of the type expected by sprintf %ls. That may not be the type of the string constant (and as this is in variable arguments, there isn't any implicit conversion to const wchar_t * like you would get with a function prototype - I'm not sure if anything ensures this code is only reached, regardless of language, if the argument does actually (after any casts present in the source code) point to the correct wchar_t type). -- Joseph S. Myers jos...@codesourcery.com