ubuntu在eclipse 中 用yaml-cpp 库 让eclipse支持C++11特性

本文记录了在Ubuntu环境下,使用Eclipse编译yaml-cpp库时遇到的C++11特性兼容问题及解决过程。通过修改编译器设置,加入C++11标准支持,成功解决了编译错误。

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

https://github.com/jbeder/yaml-cpp

今天想使用yaml-cpp库。下载安装后,ubuntu在eclipse下配好工程后,各种错误。想到是c++11特性的问题。

错误信息太多了,截取一部分如下:

/usr/local/include/yaml-cpp/node/detail/impl.h: At global scope:
/usr/local/include/yaml-cpp/node/detail/impl.h:162:47: error: ‘shared_memory_holder’ has not been declared
 inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
                                               ^
/usr/local/include/yaml-cpp/node/detail/impl.h: In member function ‘bool YAML::detail::node_data::remove(const Key&, int)’:
/usr/local/include/yaml-cpp/node/detail/impl.h:168:31: error: ‘next’ is not a member of ‘std’
       kv_pairs::iterator jt = std::next(it);
                               ^
/usr/local/include/yaml-cpp/node/detail/impl.h: At global scope:
/usr/local/include/yaml-cpp/node/detail/impl.h:189:37: error: ‘shared_memory_holder’ has not been declared
                                     shared_memory_holder pMemory) {
                                     ^
/usr/local/include/yaml-cpp/node/detail/impl.h:209:41: error: ‘shared_memory_holder’ has not been declared
                                         shared_memory_holder pMemory) {
                                         ^
/usr/local/include/yaml-cpp/node/detail/impl.h: In static member function ‘static YAML::detail::node& YAML::detail::node_data::convert_to_node(const T&, int)’:
/usr/local/include/yaml-cpp/node/detail/impl.h:212:10: error: base operand of ‘->’ is not a pointer
   pMemory->merge(*value.m_pMemory);
          ^
/usr/local/include/yaml-cpp/node/detail/impl.h:212:25: error: ‘class YAML::Node’ has no member named ‘m_pMemory’
   pMemory->merge(*value.m_pMemory);
                         ^
make: *** [src/yamldemo.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

Project->Properties->C/C++ Build->Settings->GCC G++ Compiler->Miscellaneous->Other flags 将-c -fmessage-length=0 改为 -c -fmessage-length=0 -std=c++11

 

 

好了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值