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>

Logo

欢迎加入 MCP 技术社区!与志同道合者携手前行,一同解锁 MCP 技术的无限可能!

更多推荐