Question Details

No question body available.

Tags

c msvcrt

Answers (1)

Accepted Answer Available
Accepted Answer
July 14, 2026 Score: 7 Rep: 94 Quality: Expert Completeness: 80%

Use CRTSTDIOISOWIDESPECIFIERS; it is the CRT opt-in for making swprintf treat %s as char * and %ls as wchart instead of the legacy MSVC %s = wchar_t behavior.

Define it before using the CRT declarations, or set it as a project-wide preprocessor definition:

c
#define CRTSTDIOISOWIDESPECIFIERS

#include #include

int main(void) { wchart buf[100]; const char narrow = "narrow"; const wchar_t wide = L"wide";

swprintf(buf, sizeof buf / sizeof buf[0], L"%s %ls", narrow, wide); }

Microsoft's C++ team described CRTSTDIOISOWIDESPECIFIERS as the switch to get C99/ISO wide-format specifier semantics for CRT functions such as the wide printf/scanf family: Format Specifiers Checking.

This is separate from CRTNONCONFORMINGSWPRINTFS. The latter selects the old non-standard swprintf form without the count parameter; the current CRT swprintf signature includes the sizet count argument, as documented by Microsoft for swprintf](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l).