ahm*_*can 2 c c++ macros unsigned constants
在C/C++中,说(1U)与((unsigned int)1)?之间有区别吗?我更喜欢第二个,但我担心第二个可能在运行时进行类型转换(即额外的cpu周期),而第一个在编译时获得正确的类型.谢谢.
(1U)
((unsigned int)1)
R..*_*R.. 5
他们不等同.1U在#if预处理指令中有效.(unsigned int)1是预处理器级别的语法错误.然而,你可以制作它(unsigned)+1,它在预处理器中是有效的,但只是因为很少有人知道的模糊规则.
1U
#if
(unsigned int)1
(unsigned)+1
归档时间:
13 年,11 月 前
查看次数:
249 次
最近记录: