c++ - PRId16 扩展到 d

标签 c++

我正在阅读 this page上面写着

If one of the strings has an encoding prefix and the other doesn't, the one that doesn't will be considered to have the same encoding prefix as the other.

   L"Δx = %" PRId16 // at phase 4, PRId16 expands to "d"
                    // at phase 6, L"Δx = %" and "d" form L"Δx = %d"

If a UTF-8 string literal and a wide string literal are side by side, the program is ill-formed.

为什么 PRId16 扩展为 d?这是在哪里定义的?

最佳答案

在 C99(及以后)语言标准中,作为 <inttypes.h> 的一部分:

[7.8.1] Each of the following object-like macros expands to a character string literal containing a conversion specifier, possibly modified by a length modifier, suitable for use within the format argument of a formatted input/output function when converting the corresponding integer type. These macro names have the general form of PRI [...]

参见 here供在线引用。

C++标准继承了C的标准库,所以以上可以在<cinttypes>中找到.

关于c++ - PRId16 扩展到 d,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44279873/

相关文章:

c++ - 比较字符串 .c_str() 和普通字符串的区别

c++ - OpenCV - 找不到指定扩展的编码器

c++ - 关于从 int 到 double 的隐式转换的编译器警告

c++ - 如何实现包含不同类型单元格的表格?

c++ - 了解unicode codecvt

c++ - 处理父/子类关系中的循环包含

c++ - Opengl 未定义行为

c++ - c++ 中是否有使用 opencv 的函数允许将图像转换为 double ,如 MATLAB 中的 im2double?

c++ - 模板中默认类型的重载运算符

c++ - 相当于 int 的 typedef