http://joysofprogramming.com/gcc-incompatible-implicit-declaration-bzero/
这个警告加上#include <strings.h>就可以了。
The purpose of bzero() as described by the man page
bzero - write zero-valued bytes
Let’s make use of bzero in a simple program
int main(int argc, char*argv[]){
void *s;
size_t n;
bzero(s,n);
return 0;
}
Now compile the program bzero.c…
$ gcc bzero.c
You will see the following warnings.
bzero.c: In function ‘main’:
bzero.c:4: error: ‘size_t’ undeclared (first use in this function)
bzero.c:4: error: (Each undeclared identifier is reported only once
bzero.c:4: error: for each function it appears in.)
bzero.c:4: error: expected ‘;’ before ‘n’
bzero.c:5: warning: incompatible implicit declaration of built-in function ‘bzero’
bzero.c:5: error: ‘n’ undeclared (first use in this function)
This is because we missed to add the headers which declare the function bzero() and the supporting types
Let’s add the relevant header files (.h) and compile the program
#include <strings.h>
int main(int argc, char*argv[]){
void *s;
size_t n;
bzero(s,n);
return 0;
}
Compile..
$ gcc bzero.c
Now you will find that the program is successfully compiled and linked.
本文介绍了如何解决GCC编译过程中遇到的关于未声明的size_t类型和bzero()函数的警告。通过添加相应的头文件和正确声明变量类型,程序能够成功编译并链接。
18万+

被折叠的 条评论
为什么被折叠?



