G++ 中未附加到错误或警告的“注释”的含义是什么

问题描述 投票:0回答:2

在编译一些代码时,我收到了来自

g++
4.3.4 的以下奇怪消息:

...include/boost/property_tree/stream_translator.hpp: In member function 'typename
boost::enable_if<boost::property_tree::detail::is_translator<Translator>, Type>::type
boost::property_tree::basic_ptree<Key, Data, KeyCompare>::get_value(Translator) const
[with Type = ObjectType, Translator = boost::property_tree::stream_translator<char,
std::char_traits<char>, std::allocator<char>, ObjectType>, Key = std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, Data = std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, KeyCompare =
std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]':
...include/boost/property_tree/stream_translator.hpp:189: note: 'e' was declared here

附近没有任何警告或错误,我以前从未在

g++
中见过这样的事情。有人知道发生了什么事吗?

c++ boost g++ boost-propertytree
2个回答
0
投票
在这种情况下,GCC 正在尝试提供发生进一步错误的上下文。您只显示了一个片段,而不是完整的错误,但这就是正在发生的事情。

这通常发生在模板扩展期间。 GCC 正在尝试提供发生扩展的上下文,以便您有更多信息来解决问题。当您嵌套和/或复杂的模板时,这些“注释”可能非常有用。

修复这些错误的最简单方法是自上而下地工作,纠正您看到的第一个错误并移至下一个错误。


0
投票
我知道这是一个旧线程,但在升级到新版本的 wxWidgets(从 3.0 到 3.1)和 g++(现在运行 g++ 5.3.1)后,我突然看到同样的事情。

“注释”之前是一个警告,提醒您注意使用新版本 wxWidgets 中标记为已弃用的构造函数创建的类。该注释似乎只是显示了构造函数的已弃用版本的声明位置:

/home/uwake/programs/wx/cuds_db/gp/gpSimple.cpp:157:93: warning: ’wxFont::wxFont(int, int, int, int, bool, const wxString&, wxFontEncoding)’ is deprecated: use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants [-Wdeprecated-declarations] fnt = wxFont ( 12, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL, false, "Times New Roman" ); ^ In file included from /usr/local/include/wx-3.1/wx/font.h:524:0, from /usr/local/include/wx-3.1/wx/window.h:23, from /usr/local/include/wx-3.1/wx/wx.h:38, from /usr/local/include/wx-3.1/wx/wxprec.h:42, from ./wx_pch.h:14, from <command-line>:0: /usr/local/include/wx-3.1/wx/gtk/font.h:89:5: note: declared here wxFont(int size, ^

就我而言,我通过更改为不同的构造函数来消除警告和注释(尽管不是警告推荐的构造函数,这并不真正符合我的需求)。

© www.soinside.com 2019 - 2024. All rights reserved.