70,040
社区成员
发帖
与我相关
我的任务
分享linux下加入-std=c99编译选项不会有这告警,输出也是对的,你的编译环境是什么?
linux下加入-std=c99编译选项不会有这告警,输出也是对的,你的编译环境是什么?
注意
没有负整数常量。如 -1 的表达式是将一元负运算符应用到常量所表示的值,可能会引起隐式类型转换。
若整数常量过大从而无法符合后缀/底结合所允许的任何类型,且编译器支持扩展整数类型(譬如 __int128 ),则常量可能以扩展整数类型给出;否则程序为病式。
2.c: In function ‘main’:
2.c:7:37: warning: integer constant is so large that it is unsigned
printf("format of %%lld, %lld\n", -9223372036854775808ll);
^
2.c:7:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘__int128’ [-Wformat=]
printf("format of %%lld, %lld\n", -9223372036854775808ll);
理解和讨论之前请先学会如何观察!
提醒:printf是开源的。
参考:Microsoft Visual Studio 10.0\VC\crt\src\output.c
Visual C++ 2010 Express简体中文版http://pan.baidu.com/s/1bnwRVLt
[quote=引用 7 楼 liuzhenpolestar 的回复:] 谢谢你!我用的编译器是dev c++自带的,版本较老了。tdm gcc4.8.1版本。
谢谢你!我用的编译器是dev c++自带的,版本较老了。tdm gcc4.8.1版本。
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
main(void ) {
long long a=-9223372036854775808;
printf("%lld\n", a);
}
