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





你可能感兴趣的:(error debug)