如何修复 C 错误 'EFAULT undeclared'

问题:

你有类似这样的 C 代码

main.c
errno = EFAULT;

但当你尝试编译它时,你看到类似这样的错误消息

error_message.txt
main.c:4:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:4:13: error: 'EFAULT' undeclared (first use in this function)
     errno = EFAULT;

解决方案

添加

main_fixed.c
#include <errno.h>

在错误发生的源文件顶部。这将包含类似 EFAULT 的错误代码和全局 errno 变量本身。


Check out similar posts by category: C/C++, GCC Errors