调试记录- error: #error “must enable c++17“

调试记录- error: #error “must enable c++17“,第1张

调试记录- error: #error “must enable c++17“
/opt/petalinux/2021.1/sysroots/cortexa72-cortexa53-xilinx-linux/usr/include/xir/util/any.hpp:28:2: error: #error "must enable c++17"
   28 | #error "must enable c++17"
      |  ^~~~~

定位到目标文件


#pragma once
#if __has_include()  && __cplusplus > 201700
#include 
#if !__cpp_lib_any > 0
#error "must enable -std=c++17 to use std::any"
#endif
namespace xir {
using any = std::any;
namespace stdx = ::std;
}  // namespace xir
#else
#error "must enable c++17"
#endif

解决方法:
原因是写的CMakeLists.txt文件没有添加对C++17的支持,所以在工程目录下的CMakeLists.txt中添加以下语句:

SET( CMAKE_CXX_FLAGS "-std=c++17 -O3")

其中,参数CMAKE_CXX_FLAGS含义是: set compiler for c++ language
而后面的-O3(是字母opq的o,大写的欧)是用来调节编译时的优化程度的,最高为-O3,最低为-O0(即不做优化)

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5502280.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-13

发表评论

登录后才能评论

评论列表(0条)

保存