gcc編譯遇到的一些錯誤(隨時補充)

2021-06-19 00:48:51 字數 936 閱讀 4377

自從用了部落格之後,老漢發現這是個好東西啊。再也不用去各個工程專案資料夾下尋找自己做的筆記了。

現在把平時遇到的一些個錯誤放到上邊來,謹防下次再範

*n = * n + 1;
在程式中寫了上述**,

編譯器將

*當作雙目運算子,並未當作指標。正確**如下

int temp;

temp = *n;

*n = temp + 1;

網上有很多人問錯誤在哪,總結一下幾點,希望對大家有幫助

1 include 前忘記了加上「#」

2 某些關鍵字書寫錯誤,如「void」(我糊塗地把它寫成viod)

3 main前缺少分號『;』

4 引用了自定義的標頭檔案,在自定義標頭檔案中出現了上述錯誤

long a[max];

a[max]=;

問題就出在上述**上。gcc編譯器提示

error: expected expression before 『;

高手們肯定不會犯這個錯誤,新手你看出來了麼?正確形式如下

long a[max]=;
原因在於這種陣列的預設初始化需要在定義時進行,或者單獨對每個元素賦值。

我已經在標頭檔案中引用了,math.h檔案,但是依然提示該錯誤。原因在於使用math.h中宣告的庫函式還有一點特殊之處,gcc命令列必須加-lm選項,因為數學函式位於libm.so庫檔案中(這些庫檔案通常位於/lib目錄下),-lm選項告訴編譯器,程式中用到的數學函式要到這個庫檔案裡找。

tensorflow遇到的一些錯誤

1 tensorflow dtype t.dtype.base dtype attributeerror float object has no attribute dtype 參考 我報錯的行是 disc gradients disc optimizer.compute gradients dis...

安裝錯誤的gcc導致一些錯誤

出現如下錯誤 make arm linux gnueabihf gcc command not found chk include generated uapi linux version.h chk include generated utsrelease.h cc scripts mod emp...

esclipse中遇到的一些錯誤

1.用豌豆莢連線手機和電腦,在esclipse裡面真機debug時出錯console顯示 the connection to adb is down,and a severe error has occured.you must restart adb and eclipse.please ensu...