我在Xcode 5上运行的boost.log上有一个非常小的示例项目,如下所示:
#include <iostream>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/expressions/formatters/date_time.hpp>
#include <boost/log/support/date_time.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/log/utility/setup/console.hpp>
namespace logging = boost::log;
namespace keywords = boost::log::keywords;
namespace src = boost::log::sources;
namespace expr = boost::log::expressions;
int main(int argc, const char *argv[])
{
logging::add_file_log
(
keywords::file_name = "Out_%N.log",
keywords::format =
(
expr::stream
<< expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S")
<< ": [" << logging::trivial::severity
<< "] " << expr::smessage
)
);
logging::core::get()->set_filter(logging::trivial::severity >= logging::trivial::debug);
logging::add_common_attributes();
src::severity_logger< logging::trivial::severity_level > logger;
BOOST_LOG_SEV(logger, logging::trivial::warning) << "a warning message";
return 0;
}
现在一切都运行良好的命令行项目。
但是,只要我在使用默认Xcode预编译头文件的实际项目中使用剪切,我就会在boost/type_traits/detail/has_binary_operator.hpp
和boost/lexical_cast.hpp
中收到编译器错误。
预编译标题test_prefix.pch
:
//
// Prefix header for all source files in project
//
#include <Carbon/Carbon.h>
已经浪费时间摆弄Xcode中的编译器设置和项目配置,所以感谢任何反馈!
答案 0 :(得分:2)
在前缀标题中包含Carbon / Carbon.h之前,您可能需要#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
。有关详细信息,请参阅https://svn.boost.org/trac/boost/ticket/6219。