error debug

1.當出現如下警告時:

        warning: incompatible implicit declaration of built-in function ‘malloc’

可能以爲着編譯器找不到malloc!在你的include中包含stdlib.h就可以消除警告了。

2.當出現如下警告時:

        warning: unknown conversion type character 0x20 in format [-Wformat].

源碼:

printf("the result of 4%5 is: %d\n", c);

 在printf中%是有着特殊用途的,想要使用他必須這樣:%%。

3.main參數問題:

int main(int argc, char *argv[])
e.g.  ./xxx 9 6

此時:

argc = 3;
atoi(argv[1]) = 9;
atoi(argv[2]) = 6;

4. init suspiciously returned 41, it should follow 0/-E convention

該錯誤是因爲未遵循模塊的初始化函數的定義慣例,定義爲: static void __init xxx_init(void), 一般應定義成 static int 型,並用return 0表示成功,出錯用 return -Exxx表示,如 -ENOMEM等

解決方案:改成static int





發佈了29 篇原創文章 · 獲贊 55 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章