【发布时间】:2014-04-16 21:28:05
【问题描述】:
为什么当我尝试这样做时:
#include <stdio.h>
int main()
{
printf("Size of int: %d bytes\n",sizeof(int));
return 0;
}
我知道了:
warning: format "%d" expects argmuments of int type, but the second argument is of type "long unsigned int..."
(?)
如果算的话,我的操作系统是 64 位版本 12.4 的 Ubuntu。 编译器是:GNU GCC Compiler,IDE 是 Code::Blocks。
出于好奇,我在另一台运行较差的 Win7 且结构也是 64 位的机器上运行相同的代码,我得到的结果是该 int 的大小,而不是像上面那样的警告。
【问题讨论】:
-
我认为 Microsoft 不会尝试解析
printf的格式来查看参数是否正常。