0

I use Visual Studio 9 (2008). When I compile this simple program:

#include <boost/log/trivial.hpp>

int main(int /*argc*/, char** /*argv*/)
{
    BOOST_LOG_TRIVIAL(info) << "padaka";
}

I get a warning:

..\..\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>
        ]

Program works correctly, but this is really annoying when you log a lot. Any ideas how to solve it?

sehe
  • 374,641
  • 47
  • 450
  • 633
user2449761
  • 1,169
  • 13
  • 25

1 Answers1

1

It just means that a parameter is not being used.

Sadly since the warning is generated from within Boost sources, and more notably inside class templates, my experience is that the only way to silence the warning is to disable it globally (e.g. using a pragma or a compiler option):

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

My experience is that you cannot properly restore the warning (likely because of template Point-Of-Instantiations), so you may end up having to use:

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

See also: Is using #pragma warning push/pop the right way to temporarily alter warning level? and (many) others

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • so `#pragma warning(disable: 4100) \n BOOST_LOG_TRIVIAL(info) << "padaka"; \n #pragma warning(pop)` should work. Anyway it is not solving my problem, it's creating new one. – user2449761 Mar 19 '14 at 09:07
  • no, that shouldn't work. As I said, it's complicated with MSVC warnings and template instantiations. Also, what new problem is being created? If you're that overwhelmed, maybe disable the warning globally and enlist help of someone else later? – sehe Mar 19 '14 at 10:04