error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
来源:互联网 发布:red hat linux 6.0 编辑:程序博客网 时间:2024/05/22 03:17
最近发现一个奇怪的错误,错误提示如下:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
出现该段错误的源码(某公司校招技术笔试题)如下:
#include<iostream>using namespace std;main(){long x=65530;long countx=0;while(x){countx++;x=x&(x-1);}cout<<countx<<endl;return countx;}编译后错误如下图提示:
解决方法如下:在Properties -> Configuration Properties -> C/C++ -> Command Line -> Additional Options中加入/wd4430 ,如下图:
不过呢?虽然问题解决了,本人也是“知其然不知其所以然”,若哪位高手看到后可以给出这样解决问题的原因,不过个人猜测与编译器内部有关,仅供参考,此猜测的原因如下段代码:
#include<iostream>using namespace std;main(){int x=65302250;int countx=0;while(x){countx++;x=x&(x-1);}cout<<countx<<endl;return countx;}
编译过后没有任何问题!!!
可以看到,int x=65302250;
没有提示错误哦~~~
我们知道int的大小是两字节,即-32768~32767,明显超出范围了。
剩下的交给武林盟主了~~~~~~~
0 0
- Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- 解决"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .
- 解决"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int" .
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- 解决方法error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- 8.5总结
- 人机交互,十进制和二进制的对话,捎带认清八进制(女友)和十六进制(我)的本质。
- STL容器之优先队列
- 希尔排序
- 6.Python基础 循环
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- 给出现el表达式异常,但自我检查没有发现任何问题的朋友的忠告
- 职责链模式
- 【asp】Jmail组件发邮件
- iOS在照片上添加水印
- HDU 4365 Palindrome graph(几何变换+快速幂)
- hdu 5311 Hidden String(水)
- The Accomodation of Students
- 读书笔记-《 我的成功可以复制》二