0

我使用 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>
        ]

程序运行正常,但是当你记录很多时这真的很烦人。任何想法如何解决它?

4

1 回答 1

1

它只是意味着没有使用一个参数。

遗憾的是,由于警告是从 Boost 源中生成的,尤其是在类模板中,我的经验是使警告静音的唯一方法是全局禁用它(例如,使用编译指示或编译器选项):

#pragma warning(push)
#pragma warning(disable: 4100) 
#include <boost/log/trivial.hpp>
#pragma warning(pop)

我的经验是您无法正确恢复警告(可能是因为模板 Point-Of-Instantiations),因此您最终可能不得不使用:

#pragma warning(disable: 4100) 
#include <boost/log/trivial.hpp>

另请参阅: 使用#pragma warning push/pop 是临时更改警告级别的正确方法吗?和(许多)其他人

于 2014-03-18T16:17:00.340 回答