1. 程式人生 > >問題:warning: assignment makes integer from pointer without a cast [enabled by default]

問題:warning: assignment makes integer from pointer without a cast [enabled by default]

warning: assignment makes integer from pointer without a cast [enabled by default]

C語言在編譯過程中有時候會報警告:

warning: assignment makes integer from pointer without a cast [enabled by default]

這個警告其實不會導致系統執行出錯,警告的意思是賦值型別和變數型別不一致導致的。

在這個問題中一般出現的地方如下:

tempStruct *temp = tempStructGet();

這種情況就會出現上述問題,一個函式返回值為一個結構體指標看著是沒錯的但是賦值就有問題,

修改內容如下:

tempStruct *temp = (tempStruct *)tempStructGet();

將上述內容的返回值強制轉化一下就會去掉警告。