默认情况下有什么促销活动类型是那里的可变参数列表? [英] What default promotions of types are there in the variadic arguments list?

查看:156
本文介绍了默认情况下有什么促销活动类型是那里的可变参数列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我使用的printf 函数在C ++中的8位CPU(AVR)。在下面的code安全的:

For example, I use printf function in C++ for 8-bit CPU (AVR). Is the following code safe:

uint8_t a = 5;
printf("%d", a);

下面%d个预计任何 INT (16位在我的情况,至少有16位情况下),但我通过8位整数。

Here %d expects int (16-bit in my case, and at least 16-bit in any case), but I pass 8-bit integer.

请问C / C ++标准的保证,任何类型的排名比小 INT 晋升为 INT

Does C/C++ standards guarantee that any type with rank lesser than int promoted to int?

同样的问题浮动%F 的期望双击,以及其他类似的类型。

The same question for float a and %f that expects double, and other analogous types.

推荐答案

看选秀的 n1256(C99与技术勘误TC1,TC2,TC3和包括) 6.5.2.2函数调用

有关对应的省略号 ... 没有原型的功能,或参数,默认参数提升执行。

For functions without prototype, or parameters corresponding to the ellipsis ..., the default argument promotions are performed.

这些都是:默认整数促销和推广浮动双击

Those are: Default integer promotions and promotion of float to double.

默认整数优惠:等级小于 INT 提升为 INT 或<$ C $的每一个整数类型C> unsigned int类型。

Default integer promotions: Every integer type of rank less than int is promoted to int or unsigned int.

这篇关于默认情况下有什么促销活动类型是那里的可变参数列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆