我使用Visual Studio 9(2008)。 当我编译这个简单的程序时:
#include <boost/log/trivial.hpp>
int main(int /*argc*/, char** /*argv*/)
{
BOOST_LOG_TRIVIAL(info) << "padaka";
}
我收到警告:
..\..\deps\boost_1_55_0\boost/parameter/aux_/tagged_argument.hpp(123) : warning C4100: 'x' : unreferenced formal parameter
..\..\deps\boost_1_55_0\boost/log/sources/severity_feature.hpp(252) : see reference to function template instantiation 'const boost::log::v2s_mt_nt5::trivial::severity_level &boost::parameter::aux::tagged_argument<Keyword,Arg>::operator []<boost::log::v2s_mt_nt5::trivial::severity_level>(const boost::parameter::aux::default_<Keyword,Value> &) const' being compiled
with
[
Keyword=boost::log::v2s_mt_nt5::keywords::tag::severity,
Arg=const boost::log::v2s_mt_nt5::trivial::severity_level,
Value=boost::log::v2s_mt_nt5::trivial::severity_level
]
..\..\deps\boost_1_55_0\boost/log/sources/basic_logger.hpp(459) : see reference to function template instantiation 'boost::log::v2s_mt_nt5::record boost::log::v2s_mt_nt5::sources::basic_severity_logger<BaseT,LevelT>::open_record_unlocked<ArgsT>(const ArgsT &)' being compiled
with
[
BaseT=boost::log::v2s_mt_nt5::sources::basic_logger<char,boost::log::v2s_mt_nt5::sources::severity_logger_mt<boost::log::v2s_mt_nt5::trivial::severity_level>,boost::log::v2s_mt_nt5::sources::multi_thread_model<boost::log::v2s_mt_nt5::aux::light_rw_mutex>>,
LevelT=boost::log::v2s_mt_nt5::trivial::severity_level,
ArgsT=boost::parameter::aux::tagged_argument<boost::log::v2s_mt_nt5::keywords::tag::severity,const boost::log::v2s_mt_nt5::trivial::severity_level>
]
..\..\src\MRCPClient\main.cpp(5) : see reference to function template instantiation 'boost::log::v2s_mt_nt5::record boost::log::v2s_mt_nt5::sources::basic_composite_logger<CharT,FinalT,ThreadingModelT,FeaturesT>::open_record<boost::parameter::aux::tagged_argument<Keyword,Arg>>(const ArgsT &)' being compiled
with
[
CharT=char,
FinalT=boost::log::v2s_mt_nt5::sources::severity_logger_mt<boost::log::v2s_mt_nt5::trivial::severity_level>,
ThreadingModelT=boost::log::v2s_mt_nt5::sources::multi_thread_model<boost::log::v2s_mt_nt5::aux::light_rw_mutex>,
FeaturesT=boost::log::v2s_mt_nt5::sources::features<boost::log::v2s_mt_nt5::sources::severity<boost::log::v2s_mt_nt5::trivial::severity_level>>,
Keyword=boost::log::v2s_mt_nt5::keywords::tag::severity,
Arg=const boost::log::v2s_mt_nt5::trivial::severity_level,
ArgsT=boost::parameter::aux::tagged_argument<boost::log::v2s_mt_nt5::keywords::tag::severity,const boost::log::v2s_mt_nt5::trivial::severity_level>
]
程序工作正常,但是当你记录很多时,这真的很烦人。 任何想法如何解决?
答案 0 :(得分:1)
这只是意味着没有使用参数。
可悲的是,因为警告来自Boost源代码,更值得注意的是内部类模板,我的经验是,使警告静音的唯一方法是全局禁用它(例如使用编译指示或编译器选项):
#pragma warning(push)
#pragma warning(disable: 4100)
#include <boost/log/trivial.hpp>
#pragma warning(pop)
我的经验是你无法正确恢复警告(可能是因为模板实例化),所以你可能最终不得不使用:
#pragma warning(disable: 4100)
#include <boost/log/trivial.hpp>
另见: Is using #pragma warning push/pop the right way to temporarily alter warning level?和(很多)其他人