warning: this decimal constant is unsigned only in ISO C90
来源:互联网 发布:淘宝店铺没了能退款么 编辑:程序博客网 时间:2024/06/05 13:21
关于c语言中的大整数常量--by流氓兔斯基之前编译程序的时候发现了这个问题:warning: this decimal constant is unsigned only in ISO C90
找了一下解决方式,记录一下:
1 在常数后面增加一个UL标识,或者ULL表示,如4294967295UL,这样就不会报警了
2 使用十六进制的数字,如0xFFFFFFFF
3 使用gcc -std=c99 用99标准来编译
看看c的标准里面是怎么说的:
The C90 rule that the default type of a decimal integer constant is either int, long, or
unsigned long, depending on which type is large enough to hold the value without overflow,
simplifies the use of constants. The choices in C99 are int, long and long long.
C89 added the suffixes U and u to specify unsigned numbers. C99 adds LL to specify long
long.
Unlike decimal constants, octal and hexadecimal constants too large to be ints are typed as
unsigned int if within range of that type, since it is more likely that they represent bit
patterns or masks, which are generally best treated as unsigned, rather than “real” numbers.
Little support was expressed for the old practice of permitting the digits 8 and 9 in an octal
constant, so it was dropped in C89.
A proposal to add binary constants was rejected due to lack of precedent and insufficient utility.
Despite a concern that a “lower-case-l” could be taken for the numeral one at the end of a
numeric literal, the C89 Committee rejected proposals to remove this usage, primarily on the
grounds of sanctioning existing practice.
搞明白了吧,出现这个告警,其实也是gcc提醒你该升级你的编译选项了。不过最安全的还是使用十六进制,或者加上UL或者ULL这样的说明。
找了一下解决方式,记录一下:
1 在常数后面增加一个UL标识,或者ULL表示,如4294967295UL,这样就不会报警了
2 使用十六进制的数字,如0xFFFFFFFF
3 使用gcc -std=c99 用99标准来编译
看看c的标准里面是怎么说的:
The C90 rule that the default type of a decimal integer constant is either int, long, or
unsigned long, depending on which type is large enough to hold the value without overflow,
simplifies the use of constants. The choices in C99 are int, long and long long.
C89 added the suffixes U and u to specify unsigned numbers. C99 adds LL to specify long
long.
Unlike decimal constants, octal and hexadecimal constants too large to be ints are typed as
unsigned int if within range of that type, since it is more likely that they represent bit
patterns or masks, which are generally best treated as unsigned, rather than “real” numbers.
Little support was expressed for the old practice of permitting the digits 8 and 9 in an octal
constant, so it was dropped in C89.
A proposal to add binary constants was rejected due to lack of precedent and insufficient utility.
Despite a concern that a “lower-case-l” could be taken for the numeral one at the end of a
numeric literal, the C89 Committee rejected proposals to remove this usage, primarily on the
grounds of sanctioning existing practice.
搞明白了吧,出现这个告警,其实也是gcc提醒你该升级你的编译选项了。不过最安全的还是使用十六进制,或者加上UL或者ULL这样的说明。
阅读全文
0 0
- warning: this decimal constant is unsigned only in ISO C90
- warning: this decimal constant is unsigned only in ISO C90
- warning: this decimal constant is unsigned only in ISO C90
- warning: this decimal constant is unsigned only in ISO C90
- warning: this decimal constant is unsigned only in ISO C90解决办法
- 编译告警“warning: this decimal constant is unsigned only in ISO C90”
- “warning: this decimal constant is unsigned only in ISO C90”的解决办法
- decimal constant is so large that it is unsigned
- warning: ISO C90 forbids mixed declaration
- warning:ISO C90 forbids mixed declarations and code
- warning:ISO C90 forbids mixed declarations and code
- warning:ISO C90 forbids mixed declarations and code
- warning: ISO C90 forbids mixed declarations and code
- warning:ISO C90 forbids mixed declarations and code
- warning: its scope is only this definition or declaration, which is not what you want
- warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
- Warning[Pa082]:undefined behavior: the order of volatile accesses is undefined in this statement
- IAR编译 Warning[Pa082]:undefined behavior: the order of volatile accesses is undefined in this stateme
- 坐标属性
- [Linux--Shell命令]--tr命令
- sdut 2413
- Quartz-错过触发机制
- 高低字位的取值宏
- warning: this decimal constant is unsigned only in ISO C90
- Apache Spark 黑名单(Blacklist)机制介绍
- 解决$.ajax()请求异常 jQuery提示parsererror错误解决办法
- AsyncTask 源码分析
- 黑苹果 Cpu halted Power OFF自动关机
- linux下获取占用CPU资源最多的10个进程,可以使用如下命令组合: ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head linux下
- 在linux下安装Informatica
- unity中模型动态变形处理
- 求n个数的平均数,并输出大于平均数的数。以-1结束