I'm trying to build and run the tutorial examples for Boost.log
and getting a compiler error that has me stumped and could use some help. Basic details; I've done a build of boost on OS X with boost.log
included,yet when I try to compile any of the tutorial examples I get an overloaded 'operator>>'
error from inside boost log's 'trivial.hpp'
include file.
the errors are reported to be in
log/utility/explicit_operator_bool.hpp
here's the stack:
/usr/local/include/boost/log/utility/explicit_operator_bool.hpp:67:29: error: overloaded 'operator>>' must have at least one parameter of class or enumeration type [2]
In file included from /usr/local/include/boost/log/attributes/attribute_name.hpp:27:
In file included from /usr/local/include/boost/log/attributes/attribute_set.hpp:28:
In file included from /usr/local/include/boost/log/sources/basic_logger.hpp:37:
In file included from /usr/local/include/boost/log/sources/severity_logger.hpp:27:
In file included from /usr/local/include/boost/log/trivial.hpp:25:
In file included from /Volumes/Macintosh HD 2/code/Logging Tut 1/loggingTut1/loggingTut1/main.cpp:18:
Overloaded 'operator>>' must have at least one parameter of class or enumeration type in /usr/local/include/boost/log/utility/explicit_operator_bool.hpp
Had a good look around to see if anyone else had something like this and I found nothing - so can anyone explain what i've missed or what the problem might be?
The details:
I'm trying this on OS X (10.6.8) using Xcode 4.0.2
I have downloaded and built the 1_46_1 boost version and that works fine with my primary boost-based project (using Boost Asio, boost threads etc).
Boost.log
is not in the main build yet so I downloaded it from sourceforge as in this question:
boost-log-how-to-get-it-and-how-to-build-it
I copied the boost/log
directory from the downloaded branch i开发者_如何学运维nto boost_1_46_1/boost/log
directory, and copied the libs/log
directory into the boost_1_46_1/libs/log
I removed all the boost stuff from /usr/local/include/boost
and from /usr/local/lib
and then re-built using:
./bootstrap.sh --with-libraries=all --prefix=/usr/local --includedir=/usr/local/include --libdir=/usr/local/lib
followed by
sudo ./bjam install > build.log
I checked the output for errors and it looks clean - nothing reported. I have all the boost libraries and headers under /usr/local
. I checked my Asio project and it all works fine against this build (no boost log) . I created a new project for the log tutorials, set the library path and the include path and added lboost_log to the linker options.
The problem comes when trying to use the tutorial programs for Boost log - either as detailed in the Boost Log docs here or in the example included in the files from svn here
The example from SVN looks like this:
/*
* Copyright Andrey Semashev 2007 - 2011.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file main.cpp
* \author Andrey Semashev
* \date 07.11.2009
*
* \brief An example of trivial logging.
*/
// #define BOOST_ALL_DYN_LINK 1
// #define BOOST_LOG_DYN_LINK 1
#include <boost/log/trivial.hpp>
#include <boost/log/core.hpp>
#include <boost/log/filters.hpp>
int main(int argc, char* argv[])
{
// Trivial logging: all log records are written into a file
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
// Filtering may also be applied
using namespace boost::log;
core::get()->set_filter
(
filters::attr< trivial::severity_level >("Severity") >= trivial::info
);
// Now the first two lines will not pass the filter
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}
When I build the code, I get two errors:
Semantic Issue Overloaded 'operator>>' must have at least one parameter of class or enumeration type Semantic Issue Overloaded 'operator<<' must have at least one parameter of class or enumeration type
and the error is reported in the file explicit_operator_bool.hpp from Boost Log at these lines:
.
.
.
} // namespace boost
// These operators are not found through ADL
template< typename T > void operator<< (T const&, boost::log::aux::unspecified_bool_type);
template< typename T > void operator>> (T const&, boost::log::aux::unspecified_bool_type);
#define BOOST_LOG_EXPLICIT_OPERATOR_BOOL()\
.
.
.
the stack I get in Xcode is as follows:
/usr/local/include/boost/log/utility/explicit_operator_bool.hpp:67:29: error: overloaded 'operator>>' must have at least one parameter of class or enumeration type [2]
In file included from /usr/local/include/boost/log/attributes/attribute_name.hpp:27:
In file included from /usr/local/include/boost/log/attributes/attribute_set.hpp:28:
In file included from /usr/local/include/boost/log/sources/basic_logger.hpp:37:
In file included from /usr/local/include/boost/log/sources/severity_logger.hpp:27:
In file included from /usr/local/include/boost/log/trivial.hpp:25:
In file included from /Volumes/Macintosh HD 2/code/Logging Tut 1/loggingTut1/loggingTut1/main.cpp:18:
Overloaded 'operator>>' must have at least one parameter of class or enumeration type in /usr/local/include/boost/log/utility/explicit_operator_bool.hpp
so kinda answering my own question (as it might help other Xcode/OSX users out there).
Looking at the explicit_operator.bool.hpp file, there is some conditional code in there that allows us to bypass the problem templates by setting:
#define BOOST_LOG_NO_UNSPECIFIED_BOOL
the tutorials then compile and run for me.
What i'm not sure about is why this is needed or what the effect downstream might be (note that like a lot of users, i'm interested in a quick and efficient way to get a lightweight logging framework and if we have to spend time investigating the inner workings of the framework it kinda nullifies the point...)
As the comment says, its not yet a supported library so perhaps its unfair to expect too much at this stage.
Chris
精彩评论