如何修复 C/C++ size_t does not name a type
问题:
编译你的 C 或 C++ 程序时,你看到以下错误消息:
compiler_error_size_t.txt
src/main.cpp:4:11: error: 'size_t' does not name a type
size_t mySize = 32;解决方案
在发生错误的文件中(在我们的示例中,即 src/main.cpp),在顶部或附近添加以下行。它必须添加在首次使用 size_t 的行之前,通常你会在最后一个现有的 #include 语句之后添加该行:
include_stddef_fix.cpp
#include <stddef.h>添加该行后,错误应该消失。你可能需要将 said 行添加到其他文件中,因此如果错误在其他文件中重新出现,请仔细检查任何编译器错误消息。
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