文章目录
- 1.comparison between pointer and integer :
- 2.error: 'for' loop initial declarations are only allowed in C99 mode
- 3.[Error] a function-definition is not allowed here before '{' token
- 4.[Error] 'f' was not declared in this scope
- 5.error C2679
- 6.Runtime Error
- 7.[Error] cannot convert 'int (\*)[4]' to 'char (\*)[4]' for argument '1' to 'void row(char (*)[4], int)'
- 8.[Error] ld returned 1 exit status
- 9.[Error] expected constructor, destructor, or type conversion before '(' token
- 10.[Error] 'pair' does not name a type
- 11.[Error] '>>' should be '> >' within a nested template argument list
- 12. [Warning] overflow in implicit constant conversion [-Woverflow]
- 13.[Error] a function-definition is not allowed here before '{' token
- 14.[Error] reference to 'map' is ambiguous
- 15.[Error] declaration of 'int x [3]' shadows a parameter
- 16.[Error] invalid types 'int[int]' for array subscript
- 17.[Error] declaration of 'long long int b' shadows a parameter
- 18.[Error] expected unqualified-id before 'case'
- 19.[Error] expected primary-expression before 'case'
- 20.error: expected constructor, destructor, or type conversion before '.' token
- 21.Process exited with return value 3221225477
- 22.[Error] invalid types 'int[int]' for array subscript
- 23.[Error] lvalue required as left operand of assignment
- 24.[Error] base operand of '->' has non-pointer type 'STU {aka student}'
- 25.[Error] request for member 'score' in '\* o', which is of pointer type 'STU\*
- 26.expected '}' at end if input
- 27.提交代码后出现Segmentation Fault
- 28.error C2871: 'std' : a namespace with this name does not exist
- 29.“greater”: 未声明的标识符错误
- 30.[Error] 'unordered_map' was not declared in this scope
- 31.[Error] void value not ignored as it ought to be
- 32.[Error] 'reverse' was not declared in this scope
- 33.[Error] incompatible types in assignment of 'int*' to 'int [100]'
- 34.[Error] expected identifier before '(' token
- 35.VS生成项目时报错:“error LNK 1168:无法打开xxxxxx.exe进行写入
- 36.[Error] request for member 'next' in something not a structure or union
- 37.[Warning] assignment from incompatible pointer type [enabled by default]
- 38.[Error] invalid operands to binary - (have 'int' and 'char *')
- 39.[Error] expected declaration or statement at end of input
- 40.reference to 'next' is ambiguous
- 41.[Error] variably modified 'ma' at file scope
- 42.size of array "f" is too large
- 43.unordered_map头文件报错
1.comparison between pointer and integer :
比较了两种不同类型的变量
2.error: ‘for’ loop initial declarations are only allowed in C99 mode
此部分转载自:https://blog.csdn.net/imyang2007/article/details/8296331
使用gcc编译代码是报出
error: ‘for’ loop initial declarations are only allowed in C99 mode
note: use option -std=c99 or -std=gnu99 to compile your code
错误,这是因为在gcc中直接在for循环中初始化了增量:
for(int i=0;i<len;i++)
//这语法在gcc中是错误的,必须先先定义i变量:
int i;
for(i=0;i<len;i++)
//这是因为gcc基于c89标准,换成C99标准就可以在for循环内定义i变量了:
//gcc src.c -std=c99 -o src
3.[Error] a function-definition is not allowed here before ‘{’ token
检查函数定义的范围 ,在一个函数内部不允许再定义函数
4.[Error] ‘f’ was not declared in this scope
f没有进行声明
5.error C2679
此部分转载自:https://blog.csdn.net/a379039233/article/details/83755740
#include <iostream>
//#include <string>
int main()
{
std::string str = "test";
std::cout <<str<< std::endl;
return 0;
}
上述代码报错,error: C2679: 二进制“<<”: 没有找到接受“std::string”类。
iostream 里面包含的是老的string代码(Microsoft Visual Studio 14.0\VC\include) xstring,他的代码并没有重载<<操作符,如下图:
而新的C++ 标准string代码(Microsoft Visual Studio 14.0\VC\include\string) 则重载了<<,如下:
所以必须添加头文件,用最新的标准库string。
6.Runtime Error
运行错误,调用了没有分配的内存
1.一般的话就是数组越界,也就是数组开小了,数组还是开大点比较好
2.还有一次是因为没有在读入变量n时就使用了变量n
3.这一次是在栈是空的情况下,使用了st.top()
7.[Error] cannot convert ‘int (*)[4]’ to ‘char (*)[4]’ for argument ‘1’ to ‘void row(char (*)[4], int)’
我这一次是因为自定义了一个参数为字符数组的自定义函数,但是输入了一个int类型的数组
8.[Error] ld returned 1 exit status
转载自:https://www.cnblogs.com/kinson/p/7922225.html
1.这次是因为很粗心地把int main错写成了int msin()
2.这次是因为写错了自定义函数名
9.[Error] expected constructor, destructor, or type conversion before ‘(’ token
此部分转载自:https://www.cnblogs.com/xiaoZQ/p/5203580.html
10.[Error] ‘pair’ does not name a type
没有写using namespace std;
11.[Error] ‘>>’ should be ‘> >’ within a nested template argument list
需要在两个>之间加一个空格,
让queue<pair<int,int>> q;变成queue<pair<int,int> > q;
12. [Warning] overflow in implicit constant conversion [-Woverflow]
13.[Error] a function-definition is not allowed here before ‘{’ token
在一个函数内部不许再定义函数
14.[Error] reference to ‘map’ is ambiguous
原因:自定义的map变量与库中重名;
解决:修改一下变量名
15.[Error] declaration of ‘int x [3]’ shadows a parameter
16.[Error] invalid types ‘int[int]’ for array subscript
我这次是因为数组的名称写错了,在自定义的函数中写的m[],而在主函数中用的是ma[]
[Error] invalid types ‘double [100005][double]’ for
这次是因为误把一个数组名当成了int变量使用
17.[Error] declaration of ‘long long int b’ shadows a parameter
原因是定义了相同的变量
18.[Error] expected unqualified-id before ‘case’
19.[Error] expected primary-expression before ‘case’
把代码中的case改成Case就不会出现这样的情况,应该是case与标准库里的名称起了冲突。
20.error: expected constructor, destructor, or type conversion before ‘.’ token
链接:https://blog.csdn.net/glp_hit/article/details/8635049
21.Process exited with return value 3221225477
这表示编译的时候出现了错误,我这次是因为超出了定义的数组的空间。
22.[Error] invalid types ‘int[int]’ for array subscript
我这次是因为定义了一个int n;和一个int n[100];名称冲突了
23.[Error] lvalue required as left operand of assignment
https://blog.csdn.net/kerouacs/article/details/79291762
24.[Error] base operand of ‘->’ has non-pointer type ‘STU {aka student}’
注意定义变量时,如果这样写STU *p,a; 这样是定义了一个STU *型的变量p和一个STU型的变量a。
25.[Error] request for member ‘score’ in ‘* o’, which is of pointer type 'STU*
*p->a这样是不对的,应该(*p)->a
26.expected ‘}’ at end if input
一般这种情况就是缺大括号
27.提交代码后出现Segmentation Fault
https://blog.csdn.net/u010150046/article/details/77775114
28.error C2871: ‘std’ : a namespace with this name does not exist
今天用POJ做题才知道如果要用using namespace std;的话前面的头文件要有#inlcude<iostream>,否则会出线编译错误
链接:https://blog.csdn.net/zhenshiyiqie/article/details/8445237
29.“greater”: 未声明的标识符错误
头文件加上#include<functional>
30.[Error] ‘unordered_map’ was not declared in this scope
https://blog.csdn.net/fantasy_94/article/details/86425018
31.[Error] void value not ignored as it ought to be
使用的一个函数的返回值类型是void,而有对它进行了赋值处理。
32.[Error] ‘reverse’ was not declared in this scope
我这次是因为没有写algorithm头文件,reverse函数在这个头文件内。
33.[Error] incompatible types in assignment of ‘int*’ to ‘int [100]’
https://zhidao.baidu.com/question/137297696.html
34.[Error] expected identifier before ‘(’ token
https://blog.csdn.net/qq_40732350/article/details/82946117
我这次是因为给一个自定义函数起名为union,改成Union之后就好了
35.VS生成项目时报错:“error LNK 1168:无法打开xxxxxx.exe进行写入
https://blog.csdn.net/qq_27565063/article/details/80658718
36.[Error] request for member ‘next’ in something not a structure or union
没有正确的使用next类型,注意看一下next的类型
37.[Warning] assignment from incompatible pointer type [enabled by default]
不同类型的指针进行了赋值
38.[Error] invalid operands to binary - (have ‘int’ and ‘char *’)
int类型和char*类型的变量在同一行
39.[Error] expected declaration or statement at end of input
我这次是因为某个地方少了一个括号
还有可能是某一个函数或者变量没有在使用之前声明。
40.reference to ‘next’ is ambiguous
next跟库里的属性或方法重名了
上面的next是和iostream里的内容重名了,删除了头文件iostream就好了
41.[Error] variably modified ‘ma’ at file scope
https://blog.csdn.net/zhaohaibo_/article/details/89322902
42.size of array “f” is too large
之前开了一个
大小的数组,报出了上面的错误
改成了
就没事了
43.unordered_map头文件报错
https://www.cnblogs.com/llllrj/p/9510239.html