linux下C語言錯誤整理

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函數只聲明和調用了,忘了定義吧,趕緊定義一下!


 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章