常見gcc編譯警告整理以及解決方法【收藏】
1、warning: no newline at end of file
在文件最后一行加上回車鍵
解釋:在《Rationale for the C99 standard》一文中,有C99的相關(guān)信息:
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++代碼的每一行后面有一個(gè)“結(jié)束符”,也就是newline。避免當(dāng)被include的文件展開后,前一個(gè)文件的最后一行與后一個(gè)文件的第一行直接被連接成一行從而造成錯(cuò)誤。
2、warning: comparison between pointer and integer
解釋:integer與pointer比較
3、 warning: assignment discards qualifiers from pointer target type
解釋:賦值時(shí),取消了右值的限定。
4、 warning: passing argument 1 of 'send' makes pointer from integer without a cast
解釋:函數(shù)send的第一個(gè)integer型參數(shù)沒有強(qiáng)制轉(zhuǎn)換為pointer型
5、warning: comparison is always true due to limited range of data type
解釋:由于數(shù)據(jù)類型范圍的限制,比較結(jié)果一直為真。
6、warning: initialization from incompatible pointer type
解釋:不兼容指針類型的初始化
7、 warning: return makes pointer from integer without a cast
解釋:return使integer轉(zhuǎn)換為pointer,沒有加強(qiáng)制類型轉(zhuǎn)換。
8、warning: incompatible implicit declaration of built-in function 'printf'
解釋:與內(nèi)置的printf函數(shù)隱士聲明不兼容。
9、warning: initialization discards qualifiers from pointer target type
解釋:initialization取消了指針目標(biāo)類型的限定。
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_函數(shù)第一個(gè)參數(shù)的傳遞,丟棄了指針目標(biāo)類型限定。
13、warning: "protocol_type" redefined
——type重定義
14、warning: 'return' with a value, in function returning void
在void返回類型的函數(shù)中,return返回值。
編輯:admin 最后修改時(shí)間:2018-05-18