How to fix C error 'mode_t undeclared'
Problem:
You have C code like
mode_t_example.c
mode_t mode;
but when you try to compile it you see an error message like
mode_t_undeclared_output.txt
main.c: In function ‘main’:
main.c:4:2: error: unknown type name ‘mode_t’
mode_t mode;
^~~~~~
Solution
Add
fix_mode_t_error.c
#include <sys/stat.h>
at the top of the source file where the error occured. In case you want further information about what mode_t
represents, I recommend reading this blogpost.
Check out similar posts by category:
C/C++, GCC Errors
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow