According1 to the current C standard, only one of the character sequences (read as: a string) must be prefixed by a an encoding prefix, and the rest of them are treated to have the same prefix, and are concatenated into a single string.
编码前缀由_T宏决定。如果未定义 UNICODE,它将解析为空,否则它将在前面添加L
到论点。
解决方案是在第一个字符串上使用 _T 宏,其余字符串上不使用宏,并且它们将使用相同的编码:
_tprintf(_T("The size of %s is %") PRIu32 "\n", fileName, fileSize);
但您使用的 Visual Studio 版本不兼容 C99,因此缺少此功能。这似乎已在 Visual Studio 2015 中修复。
The same usage is demonstrated in the example2 in the standard.
1 (Quoted from: ISO/IEC 9899:201x 6.4.5 String literals 5)
In translation phase 6, the multibyte character sequences specified by any sequence of
adjacent character and identically-prefixed string literal tokens are concatenated into a
single multibyte character sequence. If any of the tokens has an encoding prefix, the
resulting multibyte character sequence is treated as having the same prefix; otherwise, it
is treated as a character string literal. Whether differently-prefixed wide string literal
tokens can be concatenated and, if so, the treatment of the resulting multibyte character
sequence are implementation-defined.
2 (Quoted from: ISO/IEC 9899:201x 7.8.1 Macros for format specifiers 7)
wprintf(L"The largest integer value is %020" PRIxMAX "\n", i);