我正在为我的项目使用boost_logging。
在我的一个文件中,我只使用我的日志工具:
LDBG_ << "something"
但它没有接缝编译,我有以下错误:
1>c:\boost\boost_logging\boost\logging\detail\ts\ts_win32.hpp(57) : error C2872: 'CRITICAL_SECTION' : ambiguous symbol
1> could be 'c:\program files\microsoft sdks\windows\v6.0a\include\winbase.h(314) : RTL_CRITICAL_SECTION CRITICAL_SECTION'
1> or 'c:\boost\boost135\boost\detail\lwm_win32_cs.hpp(33) : boost::detail::CRITICAL_SECTION'
奇怪的是,这在我的一台PC上工作正常,但另一方面却没有,所以可能是winbase.h包含的不同。
修改
以下是LDBG_日志的定义方式:
#include <boost/logging/format_fwd.hpp>
#include <boost/logging/format_ts.hpp>
typedef boost::logging::scenario::usage::use<
// the filter is always accurate (but slow)
//boost::logging::scenario::usage::filter_::change::always_accurate,
boost::logging::scenario::usage::filter_::change::often< 10 >,
// filter does not use levels
boost::logging::scenario::usage::filter_::level::no_levels,
// the logger is initialized once, when only one thread is running
boost::logging::scenario::usage::logger_::change::set_once_when_one_thread,
// the logger favors speed (on a dedicated thread)
boost::logging::scenario::usage::logger_::favor::speed> finder;
BOOST_DECLARE_LOG_FILTER(g_log_filter, finder::filter )
BOOST_DECLARE_LOG(g_log_dbg, finder::logger)
#define LDBG_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_dbg(), g_log_filter()->is_enabled() )
答案 0 :(得分:2)
尝试在 Windows标头之前包含boost日志标头。