CodeBlocks常见编译错误(to be updated)
2016-04-15 12:57
375 查看
第一要则,不要直接点击”编译并且运行”,而是应该点击”编译(build)”按钮,这样可以保证警告不会被忽略,一些警告是非常有用的.
第二要则:有多个错误,要先处理最前面的错误,因为后面的错误可能前面的错误引发的.所以修改最前面的错误后就可以立即重新编译,往往可以看到所有的错误信息都不见了.
每一条信息是按字母排序,可以按序查找。
格式说明: 每一条错误都提供了样例程序,编译信息以及必要的说明
编译信息格式按 文件名,程序行数,编译错误信息组织,例如
E:\chen\dream\ex.c|6|error: break statement not within loop or switch|
使用说明: 使用关键字查找本文,如undeclared
a label can only be part of a statement and a declaration is not a statement|
break statement not within loop or switch
character constant too long for its type
conflicting types for ‘XXX’
'else' without a previous 'if'
empty character constant
expected declaration or statement at end of input
expected declaration specifiers or '...' before string constant
expected expression before 'X' token
expected primary-expression before '=' token
expected identifier or '(' before '}' token
expected '=', ',', ';', 'asm' or '__attribute__' before 'X' token
expected ';' before ‘XXX’
expected '(' before '{' token
expected ')' before 'X' token
extra tokens at end of #include directive [enabled by default]|
format '%X' expects argument of type 'XXX',
'gets' is deprecated
implicit declaration of function 'XXX'
incompatible type for argument X of 'XXX
invalid operands to binary X
invalid preprocessing directive 'XXX
invalid suffix "X" on integer constant
lvalue required as left operand of assignment
missing terminating X character
情况一: missing terminating " character 漏掉了右侧的双引号
fatal error: XXX: No such file or directory
redefinition of ‘XXX’
subscripted value is neither array nor pointer nor vector
suggest parentheses around '&&' within '||'(警告)
suggest parentheses around assignment used as truth value
statement with no effect(警告)
stray '\XXX' in program
too few arguments to function 'XXX'
‘XXX’ undeclared
undefined reference to ‘XXX’
unknown type name 'fioat'
unused variable 'XXX'
#include<stdio.h>
int main(void)
{
backward: //应该放在int语句下面
int i = 0, n, a[32];
scanf("%d", &n);
while(n > 0) {
a[i] = n % 2;
i = i + 1;
n = n / 2;
}
for(i--; i >= 0; i--)
printf("%d", a[i]);
printf("\n");
goto backward;
return 0;
}
E:\chen\dream\ex.c|5|error: a label can only be part of a statement and a declaration is not a statement|
示例
#include <stdio.h>
int main(void)
{
int i=1;
if(i==1)
break;//在if里面是不可以的
return 0;
}
E:\chen\dream\ex.c|6|error: break statement not within loop or switch|
int main()
{
char *s = 'hello,world\n'; //应该用双引号
return 0;
}
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: character constant too long for its type [enabled by default]|
E:\chen\dream\ex.c|4|warning: initialization makes pointer from integer without a cast [enabled by default]|
解释:字符常量才用单引号
#include<math.h>
double pow(int x,int y) //math.h中已经有pow函数,两者不一致,可以取另外的名字
{
return x*y;
}
int main(void)
{
pow(3,5);
return 0;
}
E:\chen\dream\ex.c|3|error: conflicting types for 'pow'|
#include <stdio.h>
int main(void)
{
int year = 3;
scanf("%d", &year);
if(year % 7); //此处分号多余,导致后面的else没有配对
printf("yes\n");
else
printf("no\n");
return 0;
}
E:\chen\dream\ex.c|8|error: 'else' without a previous 'if'
int main(void)
{
char s[10]="123";
if(s[0] == '') //单引号中间有空格,而不是空的没有字符
printf("equal\n");
return 0;
}
E:\chen\dream\ex.c|5|error: empty character constant|
int main()
{
int a = 3;
return 0; //后面漏掉}
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: expected declaration or statement at end of input|
解释: 程序没有写完整,漏掉了大括号。
scanf("%d %d",&a, &b); //连个main函数都没有
E:\chen\dream\ex.c|2|error: expected declaration specifiers or '...' before string constant|
示例一
#include <stdio.h>
int main(void)
{
int a;
scanf(%d", &a); //%前面少了双引号
return 0;
}
E:\chen\dream\ex.c|5|error: expected expression before '%' token|
示例二
#include <stdio.h>
int main(void)
{
int a = 3;
if(a= = 3) //==之间不能有空格
print("yes");
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|6|error: expected expression before '=' token|
E:\chen\dream\ex.c|7|warning: implicit declaration of function 'print' [-Wimplicit-function-declaration]|
E:\chen\dream\ex.c|5|warning: variable 'a' set but not used [-Wunused-but-set-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
示例三
if(s[i]=='a'||s[i]=='A')||s[i]=='e'||s[i]=='E'||s[i]=='i'||s[i]=='I'||s[i]=='o'||s[i]=='O'||s[i]=='u'||s[i]=='U')
error: expected expression before '||' token
注意'A'的后面多写了)
error: expected primary-expression before '=' token
#include <stdio.h>
int main()
{
return 0;
}
} //此处括号是多余的
E:\chen\dream\ex.c|7|error: expected identifier or '(' before '}' token|
示例二
#include <stdio.h>
int main();
{ //其实是这一行的前面多了分号
return 0;
}
E:\chen\dream\ex.c|3|error: expected identifier or '(' before '{' token|
示例一
#include <stdio.h>
int main
{ //实际是main函数后面少了( )
return 0;
}
E:\chen\dream\ex.c|3|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
示例二
include <stdio.h> //include前面少了#
int main()
{
return 0;
}
E:\chen\dream\ex.c|1|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
示例三
#include <stdio.h>
int main(void)
{
int a
scanf("%d",&a); //前一行漏掉一个分号
return 0;
}
E:\chen\dream\ex.c|5|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'|
示例四
int flag==0; //多写了一个=
error: expected '=', ',', ';', 'asm' or '__attribute__' before '==' token
示例一
#include <stdio.h>
int main()
{
printf("hello,world\n")
return 0; //前一行漏掉一个分号
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: expected ';' before 'return'|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
原因: 上一行的语句少了分号结束(本例中是printf这一行少了分号,但是编译器显示错误在return 0这一行).
示例二
#include <stdio.h>
int main(void)
{
int i;
for(i=1, i<10; i++) //for语句里面应该恰好有两个分号,i=1后面应该是分号
printf("%d",i);
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: value computed is not used [-Wunused-value]|
E:\chen\dream\ex.c|5|error: expected ';' before ')' token|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
error: expected '(' before '{' token
示例一
#include <stdio.h>
int main()
{
printf("hello,world\n"; //此处;前面漏掉了)
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|error: expected ')' before ';' token|
E:\chen\dream\ex.c|6|error: expected ';' before '}' token|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 2 error(s), 1 warning(s) (0 minute(s), 2 second(s)) ===|
示例二
#include <stdio.h>
int main()
{
int a = 3;
printf("%d%d"a); //a前面有应该逗号把两个参数分开
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: expected ')' before 'a'|
E:\chen\dream\ex.c|5|warning: format '%d' expects a matching 'int' argument [-Wformat]|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
示例三
printf("GCD=%d LCM=%d",gcd(m,n) lcm(m,n)); //lcm前面应该有逗号
Main.c:24:37: error: expected ')' before 'lcm'
示例四
while(scanf("%d %d",&sum,&n) !EOF){ //实际上是!=
int main()
{
return 0;
}
E:\chen\dream\ex.c|1|warning: extra tokens at end of #include directive [enabled by default]|
#include <stdio.h>
int main()
{
int a;
scanf("%d", a); //应该是 &a
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat]|
E:\chen\dream\ex.c|5|warning: 'a' is used uninitialized in this function [-Wuninitialized]|
||=== Build finished: 0 error(s), 2 warning(s) (0 minute(s), 3 second(s)) ===|
||=== Run: Debug in dream (compiler: GNU GCC Compiler) ===|
解释: 这个是警告,但是该警告往往是不能忽略,初学者一般是忘记了取址&符号
示例二:
#include <stdio.h>
int main(void)
{
int a=3, b=4;
printf("%d%d", a); //两个%d后面应该有两个参数,此处只有一个a,缺了b
return 0;
}
E:\chen\dream\ex.c|5|warning: format '%d' expects a matching 'int' argument [-Wformat]|
while(gets(str)!=NULL)
warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
如果是调用库函数,可能没有包含头文件,示例没有加stdio.h.或者写错了函数名(例如把scanf写成Scanf)
如果是自定义的函数,记住调用之前一定要声明或者定义.
示例一
int main()
{
int a;
scanf("%d", &a);
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]|
E:\chen\dream\ex.c|4|warning: incompatible implicit declaration of built-in function 'scanf' [enabled by default]|
||=== Build finished: 0 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
||=== Run: Debug in dream (compiler: GNU GCC Compiler) ===|
示例二
#include <stdio.h>
int main(void)
{
int a=3;
print("%d",&a); //函数名写错
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: implicit declaration of function 'print' [-Wimplicit-function-declaration]|
obj\Debug\ex.o||In function `main':|
E:\chen\dream\ex.c|5|undefined reference to `print'|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
int main()
{
int a = sqrt("4"); //”4”错误
return 0;
}
E:\chen\dream\ex.c|4|error: incompatible type for argument 1 of 'sqrt'|
d:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\math.h|157|note: expected 'double' but argument is of type 'char *'|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
解释:调用函数时实参类型和形参类型不兼容.如示例实参是字符串(指针),而形参是double类型
int main(void)
{
int a;
scanf("%d"&a);//漏掉了逗号,把&当成二元运算符了
return 0;
}
E:\chen\dream\ex.c|5|error: invalid operands to binary & (have 'char *' and 'int')|
int main()
{
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c|1|error: invalid preprocessing directive #inclede|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
解释:预处理指令写错了.
int main()
{
int a = 3, b;
b = 2a; //本意是2*a
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: invalid suffix "a" on integer constant|
E:\chen\dream\ex.c|4|warning: variable 'b' set but not used [-Wunused-but-set-variable]|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
解释: 编译器把2a看成一个常数,a就是后缀,但是这个后缀不存在. 如3L, 2.5f的L和f就是合法的后缀.示例的错误是初学者有时候犯的,应该写成2*a.
#include <stdio.h>
int main(void)
{
int a = 3;
if(a % 3 = 0) //此处实际是==号,误写为=
printf("YES");
return 0;
}
E:\chen\dream\ex.c|5|error: lvalue required as left operand of assignment|
#include <stdio.h>
int main()
{
printf("hello,world\n);//漏掉了右边的双引号
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: missing terminating " character [enabled by default]|
E:\chen\dream\ex.c|4|error: missing terminating " character|
E:\chen\dream\ex.c|5|error: expected expression before 'return'|
E:\chen\dream\ex.c|6|error: expected ';' before '}' token|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 3 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
原因: 字符串少了应该用一对双引号,示例中右边的双引号漏掉了
示例二
#include <stdio.h>
int main(void)
{
print("yesn\");
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: implicit declaration of function 'print' [-Wimplicit-function-declaration]|
E:\chen\dream\ex.c|4|warning: missing terminating " character [enabled by default]|
E:\chen\dream\ex.c|4|error: missing terminating " character|
E:\chen\dream\ex.c|5|error: expected expression before 'return'|
E:\chen\dream\ex.c|6|error: expected ';' before '}' token|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 3 error(s), 3 warning(s) (0 minute(s), 0 second(s)) ===|
这个错误是把\n误写为 n\, 然后\起转义作用和双引号结合,导致编译器认为少了一个双引号
情况二、missing terminating ' character
char a='3; //很明显少了单引号
printf("%d %d %d\n"'a,b,c);//本例单引号实际上是逗号
情况三:missing terminating > character
#include<stdio.h //很明显少了>
error: missing terminating > character
示例一
#include <studio.h> //文件名写错了,stdio.h
int main()
{
int a, b;
scanf("%d%d", &a,&b);
return 0;
}
E:\chen\dream\ex.c|1|fatal error: studio.h: No such file or directory|
示例二 iostream不要用C提交,而是该用C++提交
#include<iostream>
原因: (1) 忘了前面已经使用该名字定义标识符了,解决办法是使用新的名字即可.
(2)很多同学在已有的程序后面再写新的程序,导致两个main出现.解决办法删掉原来的或者创建一个新文件来写新程序.
#include <stdio.h>
int main()
{
return 0;
}
int main()
{
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\dream\ex.c|6|error: redefinition of 'main'|
E:\dream\ex.c|2|note: previous definition of 'main' was here|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
int main(void)
{
int a[3]={1,2,3}, n=4;
n[2]=1; //a误写成n,n不是数组类型,也不是指针,不可以[ ]运算
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: subscripted value is neither array nor pointer nor vector|
E:\chen\dream\ex.c|4|warning: variable 'n' set but not used [-Wunused-but-set-variable]|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
int isLeap(int year)
{
if(year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
return 1;
else
return 0;
}
int main(void)
{
return 0;
}
E:\chen\dream\ex.c|4|warning: suggest parentheses around '&&' within '||' [-Wparentheses]|
解释:&&优先级比||高,为了明确此点,你可以加上括号消除这个警告。如下
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
int main()
{
int a = 3;
if(a = 4) // 此处是否为==而不是=
printf("equal\n");
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: suggest parentheses around assignment used as truth value [-Wparentheses]|
解释: 虽然只是警告, 但是对于大部分初学者来说,往往是把等于”==”误写为赋值”=”
示例一
#include <stdio.h>
int main(void)
{
23; //显然这条语句没有任何作用,可以删除
}
E:\chen\dream\ex.c|4|warning: statement with no effect [-Wunused-value]|
示例二
#include <stdio.h>
int main(void)
{
int n;
n<=10000&&n>=1;//此表达式应该和if,while之类的结合使用,否则不起作用
return 0;
}
E:\chen\dream\ex.c|5|warning: statement with no effect [-Wunused-value]|
原因有
(1)由于中文输入法的缘故,使用了中文的标点符号(全角),比如;,},+,改成英文的标点半角符号就行了(搞不清全角半角的话直接切换到英文输入环境即可)。
(2)在某个平台下格式不同的文件拿到OJ提交
示例一
#include <stdio.h>
int main()
{
int a = 3;//这里分号是全角的
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|error: stray '\357' in program|
E:\chen\dream\ex.c|4|error: stray '\274' in program|
E:\chen\dream\ex.c|4|error: stray '\233' in program|
E:\chen\dream\ex.c|5|error: expected ',' or ';' before 'return'|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 4 error(s), 2 warning(s) (0 minute(s), 5 second(s)) ===|
示例二: int main(void) //注意这里的括号
示例三
v#include <stdio.h> //前面多了一个v,导致#无法识别为预处理指令,#必须在最前面
int main(void)
{
int a#b; //#要么是逗号分成两个标志符,要么是字母构成一个完整的标识符
printf("no"\n); //\n应该放到双引号里面
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c|1|error: stray '#' in program|
E:\chen\dream\ex.c|1|error: unknown type name 'v'|
E:\chen\dream\ex.c|1|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
E:\chen\dream\ex.c|4|error: stray '#' in program|
E:\chen\dream\ex.c|5|error: stray '\' in program|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
示例四:
rem=x%2;x=x\2; // 除号写错了
error: stray '\' in program
int main()
{
int a;
scanf(); //scanf里面没有参数
return 0;
}
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: too few arguments to function 'scanf'|
解释:调用函数是参数个数少了
原因 (1)你真正忘记定义变量就直接使用了,本例就是这种情况。
(2)写错了变量(标识符)的名字,导致前后不一致,还有注意C语言区分大小写 .解决办法是保证前后使用同一个标识符
(3)写错了关键字,C语言的很多关键字都是英文单词,如continue,return,else等等,写错了改正过来即可
(4)把数字0误写成字母o
(5)使用了头文件常量,但是没有#include头文件。例如使用EOF,NULL要#include <stdio.h>
示例一
#include <stdio.h>
int main()
{
a = 3;
return 0;
}
E:\dream\ex.c 4 error: 'a' undeclared (first use in this function)|
E:\dream\ex.c 4 note: each undeclared identifier is reported only once for each function it appears in
示例二
#include <stdio.h>
int main(void)
{
int a = 3;
if(a % 3 == o) //有趣之处数字0误写成字母o
print("yes");
return 0;
}
E:\chen\dream\ex.c|5|error: 'o' undeclared (first use in this function)|
你调用了’xxx’(例子中是print)函数,但是在目标文件中却找不到它
原因
1 拼错了函数的名字,尤其要注意大小写.例子是printf,漏掉了f
2 真正漏掉了这个函数项目中要添加对应的函数(或文件)
3. 如果出现undefined reference to `WinMain@16' (或main)一般是main的函数名写错了,例如误写成mian. 还有可能就是程序中没有main函数.
4. 调用了非标准库函数,如getch()
示例
#include <stdio.h>
int main()
{
print("hello,world\n");
return 0;
}
编译信息
In function `main':
E:\dream\ex.c 4 undefined reference to `print'
fioat p(float n); //很明显应该是float
error: unknown type name 'fioat'
int main()
{
int a = 3; //a在后面没有被用到
return 0;
}
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
解释:这是一个警告,如果一个变量未使用,意味着删掉它对程序没有影响.不删掉也可以,只是多余而已.
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\main.cpp||In function 'SElemType GetTop(SqStack)':|
E:\chen\dream\main.cpp|38|warning: control reaches end of non-void function [-Wreturn-type]|
第二要则:有多个错误,要先处理最前面的错误,因为后面的错误可能前面的错误引发的.所以修改最前面的错误后就可以立即重新编译,往往可以看到所有的错误信息都不见了.
每一条信息是按字母排序,可以按序查找。
格式说明: 每一条错误都提供了样例程序,编译信息以及必要的说明
编译信息格式按 文件名,程序行数,编译错误信息组织,例如
E:\chen\dream\ex.c|6|error: break statement not within loop or switch|
使用说明: 使用关键字查找本文,如undeclared
a label can only be part of a statement and a declaration is not a statement|
break statement not within loop or switch
character constant too long for its type
conflicting types for ‘XXX’
'else' without a previous 'if'
empty character constant
expected declaration or statement at end of input
expected declaration specifiers or '...' before string constant
expected expression before 'X' token
expected primary-expression before '=' token
expected identifier or '(' before '}' token
expected '=', ',', ';', 'asm' or '__attribute__' before 'X' token
expected ';' before ‘XXX’
expected '(' before '{' token
expected ')' before 'X' token
extra tokens at end of #include directive [enabled by default]|
format '%X' expects argument of type 'XXX',
'gets' is deprecated
implicit declaration of function 'XXX'
incompatible type for argument X of 'XXX
invalid operands to binary X
invalid preprocessing directive 'XXX
invalid suffix "X" on integer constant
lvalue required as left operand of assignment
missing terminating X character
情况一: missing terminating " character 漏掉了右侧的双引号
fatal error: XXX: No such file or directory
redefinition of ‘XXX’
subscripted value is neither array nor pointer nor vector
suggest parentheses around '&&' within '||'(警告)
suggest parentheses around assignment used as truth value
statement with no effect(警告)
stray '\XXX' in program
too few arguments to function 'XXX'
‘XXX’ undeclared
undefined reference to ‘XXX’
unknown type name 'fioat'
unused variable 'XXX'
a label can only be part of a statement and a declaration is not a statement|
标号不应该放在声明处#include<stdio.h>
int main(void)
{
backward: //应该放在int语句下面
int i = 0, n, a[32];
scanf("%d", &n);
while(n > 0) {
a[i] = n % 2;
i = i + 1;
n = n / 2;
}
for(i--; i >= 0; i--)
printf("%d", a[i]);
printf("\n");
goto backward;
return 0;
}
E:\chen\dream\ex.c|5|error: a label can only be part of a statement and a declaration is not a statement|
break statement not within loop or switch
break必须在循环或switch里面。如果在if里面,if必须在循环或switch里面。示例
#include <stdio.h>
int main(void)
{
int i=1;
if(i==1)
break;//在if里面是不可以的
return 0;
}
E:\chen\dream\ex.c|6|error: break statement not within loop or switch|
character constant too long for its type
#include <stdio.h>int main()
{
char *s = 'hello,world\n'; //应该用双引号
return 0;
}
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: character constant too long for its type [enabled by default]|
E:\chen\dream\ex.c|4|warning: initialization makes pointer from integer without a cast [enabled by default]|
解释:字符常量才用单引号
conflicting types for ‘XXX’
#include<stdio.h>#include<math.h>
double pow(int x,int y) //math.h中已经有pow函数,两者不一致,可以取另外的名字
{
return x*y;
}
int main(void)
{
pow(3,5);
return 0;
}
E:\chen\dream\ex.c|3|error: conflicting types for 'pow'|
'else' without a previous 'if'
解释:else没有配对的if。#include <stdio.h>
int main(void)
{
int year = 3;
scanf("%d", &year);
if(year % 7); //此处分号多余,导致后面的else没有配对
printf("yes\n");
else
printf("no\n");
return 0;
}
E:\chen\dream\ex.c|8|error: 'else' without a previous 'if'
empty character constant
#include <stdio.h>int main(void)
{
char s[10]="123";
if(s[0] == '') //单引号中间有空格,而不是空的没有字符
printf("equal\n");
return 0;
}
E:\chen\dream\ex.c|5|error: empty character constant|
expected declaration or statement at end of input
#include <stdio.h>int main()
{
int a = 3;
return 0; //后面漏掉}
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: expected declaration or statement at end of input|
解释: 程序没有写完整,漏掉了大括号。
expected declaration specifiers or '...' before string constant
int a,b;scanf("%d %d",&a, &b); //连个main函数都没有
E:\chen\dream\ex.c|2|error: expected declaration specifiers or '...' before string constant|
expected expression before 'X' token
一般是因为写错了符号或者漏写了符号或者多敲了符号示例一
#include <stdio.h>
int main(void)
{
int a;
scanf(%d", &a); //%前面少了双引号
return 0;
}
E:\chen\dream\ex.c|5|error: expected expression before '%' token|
示例二
#include <stdio.h>
int main(void)
{
int a = 3;
if(a= = 3) //==之间不能有空格
print("yes");
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|6|error: expected expression before '=' token|
E:\chen\dream\ex.c|7|warning: implicit declaration of function 'print' [-Wimplicit-function-declaration]|
E:\chen\dream\ex.c|5|warning: variable 'a' set but not used [-Wunused-but-set-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
示例三
if(s[i]=='a'||s[i]=='A')||s[i]=='e'||s[i]=='E'||s[i]=='i'||s[i]=='I'||s[i]=='o'||s[i]=='O'||s[i]=='u'||s[i]=='U')
error: expected expression before '||' token
注意'A'的后面多写了)
expected primary-expression before '=' token
if(l!==l1) //多写了=error: expected primary-expression before '=' token
expected identifier or '(' before '}' token
示例一#include <stdio.h>
int main()
{
return 0;
}
} //此处括号是多余的
E:\chen\dream\ex.c|7|error: expected identifier or '(' before '}' token|
示例二
#include <stdio.h>
int main();
{ //其实是这一行的前面多了分号
return 0;
}
E:\chen\dream\ex.c|3|error: expected identifier or '(' before '{' token|
expected '=', ',', ';', 'asm' or '__attribute__' before 'X' token
少了或者多写了符号示例一
#include <stdio.h>
int main
{ //实际是main函数后面少了( )
return 0;
}
E:\chen\dream\ex.c|3|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
示例二
include <stdio.h> //include前面少了#
int main()
{
return 0;
}
E:\chen\dream\ex.c|1|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
示例三
#include <stdio.h>
int main(void)
{
int a
scanf("%d",&a); //前一行漏掉一个分号
return 0;
}
E:\chen\dream\ex.c|5|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'|
示例四
int flag==0; //多写了一个=
error: expected '=', ',', ';', 'asm' or '__attribute__' before '==' token
expected ';' before ‘XXX’
少了分号示例一
#include <stdio.h>
int main()
{
printf("hello,world\n")
return 0; //前一行漏掉一个分号
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: expected ';' before 'return'|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
原因: 上一行的语句少了分号结束(本例中是printf这一行少了分号,但是编译器显示错误在return 0这一行).
示例二
#include <stdio.h>
int main(void)
{
int i;
for(i=1, i<10; i++) //for语句里面应该恰好有两个分号,i=1后面应该是分号
printf("%d",i);
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: value computed is not used [-Wunused-value]|
E:\chen\dream\ex.c|5|error: expected ';' before ')' token|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
expected '(' before '{' token
for{b=1;b<=50;b++} //显然(被误写成了{error: expected '(' before '{' token
expected ')' before 'X' token
一般是漏掉了)号,但是也有其他情况。示例一
#include <stdio.h>
int main()
{
printf("hello,world\n"; //此处;前面漏掉了)
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|error: expected ')' before ';' token|
E:\chen\dream\ex.c|6|error: expected ';' before '}' token|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 2 error(s), 1 warning(s) (0 minute(s), 2 second(s)) ===|
示例二
#include <stdio.h>
int main()
{
int a = 3;
printf("%d%d"a); //a前面有应该逗号把两个参数分开
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: expected ')' before 'a'|
E:\chen\dream\ex.c|5|warning: format '%d' expects a matching 'int' argument [-Wformat]|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
示例三
printf("GCD=%d LCM=%d",gcd(m,n) lcm(m,n)); //lcm前面应该有逗号
Main.c:24:37: error: expected ')' before 'lcm'
示例四
while(scanf("%d %d",&sum,&n) !EOF){ //实际上是!=
extra tokens at end of #include directive [enabled by default]|
#include <stdio.h>#include <stdlib.h.> //每个预处理指令如#include应该单独占据一行int main()
{
return 0;
}
E:\chen\dream\ex.c|1|warning: extra tokens at end of #include directive [enabled by default]|
format '%X' expects argument of type 'XXX',
示例一#include <stdio.h>
int main()
{
int a;
scanf("%d", a); //应该是 &a
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat]|
E:\chen\dream\ex.c|5|warning: 'a' is used uninitialized in this function [-Wuninitialized]|
||=== Build finished: 0 error(s), 2 warning(s) (0 minute(s), 3 second(s)) ===|
||=== Run: Debug in dream (compiler: GNU GCC Compiler) ===|
解释: 这个是警告,但是该警告往往是不能忽略,初学者一般是忘记了取址&符号
示例二:
#include <stdio.h>
int main(void)
{
int a=3, b=4;
printf("%d%d", a); //两个%d后面应该有两个参数,此处只有一个a,缺了b
return 0;
}
E:\chen\dream\ex.c|5|warning: format '%d' expects a matching 'int' argument [-Wformat]|
'gets' is deprecated
这个警告目前可以忽略,是说不鼓励使用getswhile(gets(str)!=NULL)
warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
implicit declaration of function 'XXX'
解释: 缺少函数原型.如果是调用库函数,可能没有包含头文件,示例没有加stdio.h.或者写错了函数名(例如把scanf写成Scanf)
如果是自定义的函数,记住调用之前一定要声明或者定义.
示例一
int main()
{
int a;
scanf("%d", &a);
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]|
E:\chen\dream\ex.c|4|warning: incompatible implicit declaration of built-in function 'scanf' [enabled by default]|
||=== Build finished: 0 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
||=== Run: Debug in dream (compiler: GNU GCC Compiler) ===|
示例二
#include <stdio.h>
int main(void)
{
int a=3;
print("%d",&a); //函数名写错
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: implicit declaration of function 'print' [-Wimplicit-function-declaration]|
obj\Debug\ex.o||In function `main':|
E:\chen\dream\ex.c|5|undefined reference to `print'|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
incompatible type for argument X of 'XXX
#include <math.h>int main()
{
int a = sqrt("4"); //”4”错误
return 0;
}
E:\chen\dream\ex.c|4|error: incompatible type for argument 1 of 'sqrt'|
d:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\math.h|157|note: expected 'double' but argument is of type 'char *'|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
解释:调用函数时实参类型和形参类型不兼容.如示例实参是字符串(指针),而形参是double类型
invalid operands to binary X
#include <stdio.h>int main(void)
{
int a;
scanf("%d"&a);//漏掉了逗号,把&当成二元运算符了
return 0;
}
E:\chen\dream\ex.c|5|error: invalid operands to binary & (have 'char *' and 'int')|
invalid preprocessing directive 'XXX
#inclede <iostream> //include写错了int main()
{
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c|1|error: invalid preprocessing directive #inclede|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
解释:预处理指令写错了.
invalid suffix "X" on integer constant
#include <stdio.h>int main()
{
int a = 3, b;
b = 2a; //本意是2*a
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: invalid suffix "a" on integer constant|
E:\chen\dream\ex.c|4|warning: variable 'b' set but not used [-Wunused-but-set-variable]|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
解释: 编译器把2a看成一个常数,a就是后缀,但是这个后缀不存在. 如3L, 2.5f的L和f就是合法的后缀.示例的错误是初学者有时候犯的,应该写成2*a.
lvalue required as left operand of assignment
解释:赋值号的左边应该是左值(一般而言是变量)#include <stdio.h>
int main(void)
{
int a = 3;
if(a % 3 = 0) //此处实际是==号,误写为=
printf("YES");
return 0;
}
E:\chen\dream\ex.c|5|error: lvalue required as left operand of assignment|
missing terminating X character
情况一: missing terminating " character 漏掉了右侧的双引号
示例一#include <stdio.h>
int main()
{
printf("hello,world\n);//漏掉了右边的双引号
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: missing terminating " character [enabled by default]|
E:\chen\dream\ex.c|4|error: missing terminating " character|
E:\chen\dream\ex.c|5|error: expected expression before 'return'|
E:\chen\dream\ex.c|6|error: expected ';' before '}' token|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 3 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
原因: 字符串少了应该用一对双引号,示例中右边的双引号漏掉了
示例二
#include <stdio.h>
int main(void)
{
print("yesn\");
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|warning: implicit declaration of function 'print' [-Wimplicit-function-declaration]|
E:\chen\dream\ex.c|4|warning: missing terminating " character [enabled by default]|
E:\chen\dream\ex.c|4|error: missing terminating " character|
E:\chen\dream\ex.c|5|error: expected expression before 'return'|
E:\chen\dream\ex.c|6|error: expected ';' before '}' token|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 3 error(s), 3 warning(s) (0 minute(s), 0 second(s)) ===|
这个错误是把\n误写为 n\, 然后\起转义作用和双引号结合,导致编译器认为少了一个双引号
情况二、missing terminating ' character
char a='3; //很明显少了单引号
printf("%d %d %d\n"'a,b,c);//本例单引号实际上是逗号
情况三:missing terminating > character
#include<stdio.h //很明显少了>
error: missing terminating > character
fatal error: XXX: No such file or directory
写错文件名了,例如有写成stdio,h的。示例一
#include <studio.h> //文件名写错了,stdio.h
int main()
{
int a, b;
scanf("%d%d", &a,&b);
return 0;
}
E:\chen\dream\ex.c|1|fatal error: studio.h: No such file or directory|
示例二 iostream不要用C提交,而是该用C++提交
#include<iostream>
redefinition of ‘XXX’
解释 XXX重复定义了原因: (1) 忘了前面已经使用该名字定义标识符了,解决办法是使用新的名字即可.
(2)很多同学在已有的程序后面再写新的程序,导致两个main出现.解决办法删掉原来的或者创建一个新文件来写新程序.
#include <stdio.h>
int main()
{
return 0;
}
int main()
{
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\dream\ex.c|6|error: redefinition of 'main'|
E:\dream\ex.c|2|note: previous definition of 'main' was here|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
subscripted value is neither array nor pointer nor vector
#include <stdio.h>int main(void)
{
int a[3]={1,2,3}, n=4;
n[2]=1; //a误写成n,n不是数组类型,也不是指针,不可以[ ]运算
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: subscripted value is neither array nor pointer nor vector|
E:\chen\dream\ex.c|4|warning: variable 'n' set but not used [-Wunused-but-set-variable]|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
suggest parentheses around '&&' within '||'(警告)
#include <stdio.h>int isLeap(int year)
{
if(year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
return 1;
else
return 0;
}
int main(void)
{
return 0;
}
E:\chen\dream\ex.c|4|warning: suggest parentheses around '&&' within '||' [-Wparentheses]|
解释:&&优先级比||高,为了明确此点,你可以加上括号消除这个警告。如下
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
suggest parentheses around assignment used as truth value
#include <stdio.h>int main()
{
int a = 3;
if(a = 4) // 此处是否为==而不是=
printf("equal\n");
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|warning: suggest parentheses around assignment used as truth value [-Wparentheses]|
解释: 虽然只是警告, 但是对于大部分初学者来说,往往是把等于”==”误写为赋值”=”
statement with no effect(警告)
语句没有作用示例一
#include <stdio.h>
int main(void)
{
23; //显然这条语句没有任何作用,可以删除
}
E:\chen\dream\ex.c|4|warning: statement with no effect [-Wunused-value]|
示例二
#include <stdio.h>
int main(void)
{
int n;
n<=10000&&n>=1;//此表达式应该和if,while之类的结合使用,否则不起作用
return 0;
}
E:\chen\dream\ex.c|5|warning: statement with no effect [-Wunused-value]|
stray '\XXX' in program
总体来说是程序不认识的符号。原因有
(1)由于中文输入法的缘故,使用了中文的标点符号(全角),比如;,},+,改成英文的标点半角符号就行了(搞不清全角半角的话直接切换到英文输入环境即可)。
(2)在某个平台下格式不同的文件拿到OJ提交
示例一
#include <stdio.h>
int main()
{
int a = 3;//这里分号是全角的
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|4|error: stray '\357' in program|
E:\chen\dream\ex.c|4|error: stray '\274' in program|
E:\chen\dream\ex.c|4|error: stray '\233' in program|
E:\chen\dream\ex.c|5|error: expected ',' or ';' before 'return'|
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
E:\chen\dream\ex.c|6|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 4 error(s), 2 warning(s) (0 minute(s), 5 second(s)) ===|
示例二: int main(void) //注意这里的括号
示例三
v#include <stdio.h> //前面多了一个v,导致#无法识别为预处理指令,#必须在最前面
int main(void)
{
int a#b; //#要么是逗号分成两个标志符,要么是字母构成一个完整的标识符
printf("no"\n); //\n应该放到双引号里面
return 0;
}
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\ex.c|1|error: stray '#' in program|
E:\chen\dream\ex.c|1|error: unknown type name 'v'|
E:\chen\dream\ex.c|1|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
E:\chen\dream\ex.c|4|error: stray '#' in program|
E:\chen\dream\ex.c|5|error: stray '\' in program|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
示例四:
rem=x%2;x=x\2; // 除号写错了
error: stray '\' in program
too few arguments to function 'XXX'
#include <stdio.h>int main()
{
int a;
scanf(); //scanf里面没有参数
return 0;
}
E:\chen\dream\ex.c||In function 'main':|
E:\chen\dream\ex.c|5|error: too few arguments to function 'scanf'|
解释:调用函数是参数个数少了
‘XXX’ undeclared
解释 你使用了标识符‘XXX’,但是没有看到它的定义原因 (1)你真正忘记定义变量就直接使用了,本例就是这种情况。
(2)写错了变量(标识符)的名字,导致前后不一致,还有注意C语言区分大小写 .解决办法是保证前后使用同一个标识符
(3)写错了关键字,C语言的很多关键字都是英文单词,如continue,return,else等等,写错了改正过来即可
(4)把数字0误写成字母o
(5)使用了头文件常量,但是没有#include头文件。例如使用EOF,NULL要#include <stdio.h>
示例一
#include <stdio.h>
int main()
{
a = 3;
return 0;
}
E:\dream\ex.c 4 error: 'a' undeclared (first use in this function)|
E:\dream\ex.c 4 note: each undeclared identifier is reported only once for each function it appears in
示例二
#include <stdio.h>
int main(void)
{
int a = 3;
if(a % 3 == o) //有趣之处数字0误写成字母o
print("yes");
return 0;
}
E:\chen\dream\ex.c|5|error: 'o' undeclared (first use in this function)|
undefined reference to ‘XXX’
解释:你调用了’xxx’(例子中是print)函数,但是在目标文件中却找不到它
原因
1 拼错了函数的名字,尤其要注意大小写.例子是printf,漏掉了f
2 真正漏掉了这个函数项目中要添加对应的函数(或文件)
3. 如果出现undefined reference to `WinMain@16' (或main)一般是main的函数名写错了,例如误写成mian. 还有可能就是程序中没有main函数.
4. 调用了非标准库函数,如getch()
示例
#include <stdio.h>
int main()
{
print("hello,world\n");
return 0;
}
编译信息
In function `main':
E:\dream\ex.c 4 undefined reference to `print'
unknown type name 'fioat'
写错了类型名fioat p(float n); //很明显应该是float
error: unknown type name 'fioat'
unused variable 'XXX'
#include <stdio.h>int main()
{
int a = 3; //a在后面没有被用到
return 0;
}
E:\chen\dream\ex.c|4|warning: unused variable 'a' [-Wunused-variable]|
解释:这是一个警告,如果一个变量未使用,意味着删掉它对程序没有影响.不删掉也可以,只是多余而已.
||=== Build: Debug in dream (compiler: GNU GCC Compiler) ===|
E:\chen\dream\main.cpp||In function 'SElemType GetTop(SqStack)':|
E:\chen\dream\main.cpp|38|warning: control reaches end of non-void function [-Wreturn-type]|
相关文章推荐
- type="button" ,"submit" 的区别(转)
- Django笔记 生产环境部署 gunicorn+nginx+supervisor
- Leetcode题解 125. Valid Palindrome
- STL之sort快排小结
- HttpUrlConnection的简单使用--get和post的简单使用
- Quick Tip: Don’t Forget the Viewport Meta Tag
- Android NDK开发method GetStringUTFChars’could not be resolved
- java并发:阻塞队列
- 调试扫描头
- 教程:欢迎使用CSDN-markdown编辑器
- MPI编程及性能优化
- 滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(4月15日)
- C++类内存布局图(成员函数和成员变量分开讨论)
- STL之qsort快排小结
- 完全新手: windows64 bit 安装python2.7.11 和 scikit-learn
- Linux7.2中用 命令 find / -mtime +1 真的是查找1天前创建的文件吗?
- IDEA - Tomcat 配置虚拟目录用来存放图片和访问图片
- 代码阅读工具使用入门
- Android应用程序的debug属性
- CF 136A present