boost :: priority_queue中的警告 [英] Warnings in boost::priority_queue
问题描述
当我尝试构建"priority_queue_example.cpp"时,会在声明我的priority_queue的行上收到指向"priority_queue_example.h"的警告(以及类似的错误).警告是
When I try to build "priority_queue_example.cpp" it get these warnings(and so errors) pointing to "priority_queue_example.h" on the line where my priority_queue is declared. The warnings are,
1> priority_queue_example.cpp
1>c:\Projects\lib\boost\boost\heap\detail\stable_heap.hpp(102): error C2220: warning treated as error - no 'object' file generated
1>c:\Projects\lib\boost\boost\heap\detail\stable_heap.hpp(102): warning
C4100: 'rhs' : unreferenced formal parameter
1> c:\Projects\lib\boost\boost\heap\detail\stable_heap.hpp(102) : while compiling class template member function 'boost::heap::detail::size_holder<false,size_t>::size_holder(const boost::heap::detail::size_holder<false,size_t> &)'
1> c:\Projects\lib\boost\boost\heap\detail\stable_heap.hpp(189) : see reference to function template instantiation 'boost::heap::detail::size_holder<false,size_t>::size_holder(const boost::heap::detail::size_holder<false,size_t> &)' being compiled
1> c:\Projects\lib\boost\boost\heap\detail\stable_heap.hpp(151) : see reference to class template instantiation 'boost::heap::detail::size_holder<false,size_t>' being compiled
1> c:\Projects\lib\boost\boost\heap\priority_queue.hpp(65) : see reference to class template instantiation 'boost::heap::detail::heap_base<T,myObjectPtrCompare,false,unsigned __int64,false>' being compiled
1> with
1> [
1> T=myObject *
1> ]
1> c:\Projects\priority_queue_example.h(193) : see reference to class template instantiation 'boost::heap::priority_queue<myObject *,boost::heap::compare<myObjectPtrCompare>,boost::parameter::void_,boost::parameter::void_,boost::parameter::void_>' being compiledcompare<ObjectPtrCompare>,boost::parameter::void_,boost::parameter::void
我的priority_queue被声明为
My priority_queue is declared as,
mutable boost::heap::priority_queue<myObject*, boost::heap::compare<myObjectPtrCompare> > hp;
我不确定这是什么意思.我可以解决这个问题吗?
I'm not sure what this means. Can I fix this?
这是我定义的比较类,
struct myObjectPtrCompare
{
bool operator()(const myObject* lhs, const myObject* rhs) const
{
return (lhs->getProp() < rhs->getProp());
}
};
推荐答案
在/W4中,Boost并非没有警告.这意味着即使您的代码是corect,也可能会有虚假的警告.
Boost is not warning-free with /W4. That means that there could be spurious warnings, even if your code is corect.
You can disable specific warnings as specified in this article: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-suppress-compiler-warnings
-
在解决方案资源管理器中,选择要在其中禁止显示警告的项目或源文件.
In Solution Explorer, choose the project or source file in which you want to suppress warnings.
在菜单栏上,选择视图",属性页".
On the menu bar, choose View, Property Pages.
选择配置属性"类别,选择"C/C ++"类别,然后选择高级"页面.
Choose the Configuration Properties category, choose the C/C++ category, and then choose the Advanced page.
执行以下步骤之一:
-
在禁用特定警告"框中,指定要禁止显示的警告的错误代码,以分号分隔.
In the Disable Specific Warnings box, specify the error codes of the warnings that you want to suppress, separated by a semicolon.
在禁用特定警告"框中,选择编辑"以显示更多选项.
In the Disable Specific Warnings box, choose Edit to display more options.
选择确定"按钮,然后重新构建解决方案.
Choose the OK button, and then rebuild the solution.
这篇关于boost :: priority_queue中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!