天天看點

GCC編譯警告和錯誤

常見gcc 編譯錯誤整理(開始) 1

1 error: expected expression before 'else'

else之前無表達式。

2 error: lvalue required as left operand of assignment

左值問題。

3 error: invalid storage class for function 'XXXXXX'

在檔案的某個地方,丢失了一個大括号‘}’。

常見gcc編譯警告整理(開始)

1、warning: no newline at end of file

在檔案最後一行加上Enter鍵

解釋:在《Rationale for the C99 standard》一文中,有C99的相關資訊:

A backslash immediately before a newline has long been used to continue string literals, as well as preprocessing command lines. In the interest of easing machine generation of C, and of transporting code to machines with restrictive physical line lengths, the C89 Committee generalized this mechanism to permit any token to be continued by interposing a backslash/newline sequence.

c/c++代碼的每一行後面有一個“結束符”,也就是newline。避免當被include的檔案展開後,前一個檔案的最後一行與後一個檔案的第一行直接被連接配接成一行進而造成錯誤。

2、warning: comparison between pointer and integer

解釋:integer與pointer比較

3、 warning: assignment discards qualifiers from pointer target type

解釋:指派時,取消了右值的限定。

4、 warning: passing argument 1 of 'send' makes pointer from integer without a cast

解釋:函數send的第一個integer型參數沒有強制轉換為pointer型

5、warning: comparison is always true due to limited range of data type

解釋:由于資料類型範圍的限制,比較結果一直為真。

6、warning: initialization from incompatible pointer type

解釋:不相容指針類型的初始化

7、 warning: return makes pointer from integer without a cast

解釋:return使integer轉換為pointer,沒有加強制類型轉換。

8、warning: incompatible implicit declaration of built-in function 'printf'

解釋:與内置的printf函數隐士聲明不相容。

9、warning: initialization discards qualifiers from pointer target type

解釋:initialization取消了指針目标類型的限定。

10、warning: comparison is always false due to limited range of data type

由于類型限制,比較一直是假

11、warning: assignment from incompatible pointer type

不相容的指針間指派

12、warning: passing argument 1 of 'mes_read_time' discards qualifiers from pointer target type12、

mes_函數第一個參數的傳遞,丢棄了指針目标類型限定。

13、warning: "protocol_type" redefined

——type重定義

14、warning: 'return' with a value, in function returning void

在void傳回類型的函數中,return傳回值。

轉載于:https://www.cnblogs.com/johnnyflute/p/3595699.html