c++ - 如何解决编译器警告 'implicit declaration of function memset'

标签 c++ c

我的 c 代码使用“memset”和“close”。 我已经添加:

#include <stdio.h>
#include <glib.h>
#include <stdlib.h>

但我仍然收到这些警告:

main.c:259: warning: implicit declaration of function ‘memset’
main.c:259: warning: incompatible implicit declaration of built-in function ‘memset’
main.c:268: warning: implicit declaration of function ‘close’
main.c:259: warning: incompatible implicit declaration of built-in function ‘close’

您能告诉我如何解决这些警告吗?

谢谢。

最佳答案

你需要:

#include <string.h> /* memset */
#include <unistd.h> /* close */

在您的代码中。

引用:close 的 POSIX ,memset 的 C 标准。

关于c++ - 如何解决编译器警告 'implicit declaration of function memset',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2144617/

相关文章:

c++ - 将类型安全代码与运行时决策相结合

python - Python 的性能是否物有所值?

c - 如何组织从服务器获取的json数据?

c++ - 动态/在执行期间重新定义或添加类成员函数

c++ - 每个版本更新的代码更改

c++ - 为什么我有条件地包含 stdafx.h 后会出现编译错误?

c - 如何检测未终止的注释并向代码中的标准错误流写入 "Error: line X: unterminated comment"的错误消息?

c++ - 以编程方式确定 native .exe 是 32 位还是 64 位

c++ - 在 VC++ 中引用静态库

c - malloc 不适用于 double 类型数组