error: ‘std::memset’ has not been declared问题的解放办法

本文详细解释了在使用C++标准库函数如std::sprintf、std::strerror等时遇到未定义错误的原因及解决方案。通过正确包含相应的头文件,可以避免此类编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

error: ‘std::memchr’ is not a member of ‘std’
error: ‘std::sprintf’ has not been declared
error: ‘std::strcmp’ has not been declared
error: ‘std::strlen’ has not been declared
error: ‘std::memcpy’ has not been declared
error: ‘std::memset’ has not been declared
error: ‘std::strerror’ has not been declared

出现上述问题,一般是因为头文件没有包含。GNU的某些版本是可以相互包含的,有些则需要各自包含。故解决办法是在出现错误的文件里包含响应的头文件,如下:

// C++ header for:
// std::sprintf, std::strerror
#include <cstdio> // Not the C header <stdio.h>

// C++ header for:
// std::strlen, std::memchr, std::strcmp, std:memcpy, std::memset
#include <cstring> // Not the C header <string.h>

35 0 F:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\cstdint In file included from F:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/cstdint 6 C:\Users\余伟杰\Desktop\哈希算法.cpp from C:\Users\余伟杰\Desktop\哈希算法.cpp 32 2 F:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\c++0x_warning.h [Error] #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. 18 7 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' does not name a type 52 23 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' does not name a type 100 5 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' does not name a type 101 5 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' does not name a type 102 5 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' does not name a type 105 26 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' does not name a type 182 30 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' does not name a type 182 46 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' has not been declared 192 30 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' does not name a type 192 47 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' has not been declared 202 40 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' does not name a type C:\Users\余伟杰\Desktop\哈希算法.cpp In member function 'void MD5::reset()': 43 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'state' was not declared in this scope 47 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'count' was not declared in this scope 48 16 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'buffer' was not declared in this scope C:\Users\余伟杰\Desktop\哈希算法.cpp In member function 'void MD5::update(const int*, size_t)': 53 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' was not declared in this scope 55 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'index' was not declared in this scope 55 18 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'count' was not declared in this scope 60 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'partLen' was not declared in this scope 62 21 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'buffer' was not declared in this scope 64 18 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'i' was not declared in this scope 69 13 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'i' was not declared in this scope 71 17 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'buffer' was not declared in this scope 71 39 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'i' was not declared in this scope C:\Users\余伟杰\Desktop\哈希算法.cpp In member function 'std::string MD5::final()': 76 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' was not declared in this scope 77 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' was not declared in this scope 78 17 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected ';' before 'digest' 79 22 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' does not name a type 82 16 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'count' was not declared in this scope 82 23 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'bits' was not declared in this scope 85 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'index' was not declared in this scope 86 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'padLen' was not declared in this scope 87 16 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'PADDING' was not declared in this scope 93 16 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'state' was not declared in this scope 93 23 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'digest' was not declared in this scope C:\Users\余伟杰\Desktop\哈希算法.cpp In member function 'void MD5::transform(const int*)': 106 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' was not declared in this scope 107 18 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected ';' before 'x' 109 23 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'x' was not declared in this scope 112 12 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'a' was not declared in this scope 112 15 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'b' was not declared in this scope 112 18 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'c' was not declared in this scope 112 21 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'd' was not declared in this scope 112 35 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'T' was not declared in this scope 112 39 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'FF' was not declared in this scope 122 40 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'GG' was not declared in this scope 132 40 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'HH' was not declared in this scope 142 40 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'II' was not declared in this scope 151 9 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'state' was not declared in this scope C:\Users\余伟杰\Desktop\哈希算法.cpp In static member function 'static void MD5::decode(const int*, int*, size_t)': 184 27 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint32_t' was not declared in this scope 184 36 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected ')' before 'input' C:\Users\余伟杰\Desktop\哈希算法.cpp In function 'int main()': 219 39 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected '>' before 'uint8_t' 219 39 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected '(' before 'uint8_t' 219 39 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] 'uint8_t' was not declared in this scope 219 47 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected primary-expression before '>' token 228 43 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected '>' before 'uint8_t' 228 43 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected '(' before 'uint8_t' 228 51 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected primary-expression before '>' token 232 43 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected '>' before 'uint8_t' 232 43 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected '(' before 'uint8_t' 232 51 C:\Users\余伟杰\Desktop\哈希算法.cpp [Error] expected primary-expression before '>' token 修改代码
最新发布
07-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值