How to fix C/C++ 'size_t' does not name a type
Problem:
When compiling your C or C++ program. you see the following error message:
compiler_error_size_t.txt
src/main.cpp:4:11: error: 'size_t' does not name a type
size_t mySize = 32;Solution
In the file where the error occurs (in our example, that would be src/main.cpp), add the following line at or near the top. It must be added before the line where size_t is first used, and usually you would add that line after the last existing #include statements:
include_stddef_fix.cpp
#include <stddef.h>After adding that line, the error should be gone. Possibly you need to add said line to other files as well, so carefully check any compiler error messages if the error re-appears in other files.
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