linux下C语言错误整理

来源:互联网 发布:网络交换机怎么安装 编辑:程序博客网 时间:2024/06/05 07:05

1.error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token      
   error: expected '{' at end of input                                                    

这里就是的错误就是写代码不细心造成的,可能是声明函数时,没有加“;”号,也有可能是include<stdio.h>前面没有加“#”号,或是将其它一些符号写错。


2.error: 'for' loop initial declarations are only allowed in C99 mode     

原因是在循环条件中声明变量的话,只在C99标准中支持,C90标准不支持。

例:  for (int i = 0; i < n; i++)   

        改为 int i; for(i=0;i<n;i++)


3.In function 'mian':
   error: stray '\' in program
   error: expected ')' before 'n'

main写成mian了吧大笑


4.error: conio.h: No such file or directory

将#include <conio.h> 改为#include <curses.h>


5.warning: 'struct sqlist' declared inside parameter list

例:void win(struct sqlist *l);
       void insert(struct sqlist *l,int i,int e);
       struct sqlist{

            int *elem;
            int length;
            int listsize;
       };

       

改为这样就不会出现警告了(函数声明要在结构体后面): 

       struct sqlist{

            int *elem;
            int length;
            int listsize;
       };

       void win(struct sqlist *l);
       void insert(struct sqlist *l,int i,int e);


6.error: 'OVERFLOW' undeclared (first use in this function)

exit(OVERFLOW)  改为:exit(0)   就OK了!


7.warning:assignment from incompatible pointer type

这说明在赋值的时候,赋值符左右两边指针类型不相同。

例: int *int_p;

double double_variable;

/*将指向double变量的指针赋值指向int的指针变量(这时就会出现上面的警告)*/

int_p = &double_variable;


8.error:(.text+0x7): undefined reference to `function_a'

这说明function_a函数只声明和调用了,忘了定义吧,赶紧定义一下!


 
0 0
原创粉丝点击