How to fix C error 'EFAULT undeclared'

Problem:

You have C code like

main.c
errno = EFAULT;

but when you try to compile it you see an error message like

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;

Solution

Add

main_fixed.c
#include <errno.h>

at the top of the source file where the error occured. This will include both error codes like EFAULT and the global errno variable itself.


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