[email protected]:~/langs/c$ cat 3264int.c
#include <stdio.h>
int main(){
long z;
printf("Long int size is %d bytes long!\n", sizeof(z));
return 0;
}
[email protected]:~/langs/c$ cat 3264int.c ^C
[email protected]:~/langs/c$ gcc -m32 -o 32int 3264int.c
[email protected]:~/langs/c$ gcc -m64 -o 64int 3264int.c
3264int.c: In function ‘main’:
3264int.c:4: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ cat 3264int.c
我试图改变类型z
为int,它仍然无法编译。为什么我可以在32位而不是64位编译这个?
`%zu`不是gcc特有的,实际上编译器与`printf`(库函数)支持的内容无关。 `%zu`是ANSI/ISO C语言的标准部分,已有10多年的历史。 – 2011-02-14 04:37:45