Ubuntu 18.04升级至20.04后系统自带gcc也由7.5升级至9.3出现金融新问题
原先可以编译的c++工程如今报错
error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of a non-trivial type ... leaves 94 bytes unchanged [-Werror=class-memaccess]
g++高版本检查更加严格,确定程序没有问题
通过向CMakeLists.txt
中传入-Wno-error=class-memaccess
参数抑制错误
例如
# Set C/CXX compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-error=deprecated-declarations -fstack-protector-strong -Wno-error=strict-aliasing -Wno-error=class-memaccess")
set(CMAKE_CXX_STANDARD 11)
gcc8 compiler error: class-memaccess · Issue #2931 - GitHub
gcc9编译memcpy报错writing to an object of a non-trivial type解决
原文:https://www.cnblogs.com/azureology/p/14891671.html