现在的位置: 首页 > 综合 > 正文

c:14: warning: incompatible implicit declaration of built-in function

2013年10月10日 ⁄ 综合 ⁄ 共 1061字 ⁄ 字号 评论关闭

看这个文章:http://stackoverflow.com/questions/977233/warning-incompatible-implicit-declaration-of-built-in-function-xyz

=====================================================================================================================================

In C, using a previously undeclared function constitutes an implicit declaration of the function. In an implicit declaration, the return type is int if
I recall correctly. Now, GCC has built-in definitions for some standard functions. If an implicit declaration does not match the built-in definition, you get this warning.

To fix the problem, you have to declare the functions before using them; normally you do this by including the appropriate header. I recommend not to use the -fno-builtin-* flags if possible.

Instead of stdlib.h, you should try

#include <string.h>

That's where strcpy and strncpy are
defined, at least according to the strcpy(2) man page.

The exit function
is defined in stdlib.h, though, so I don't know what's going on there.

======================================================================================================================================

说是要包含 #include <string.h>  没有问题了……我测试果然如此!!!

【上篇】
【下篇】

抱歉!评论已关闭.