c++ - 使用 Xcode 预编译 header 时 boost.log 中断

标签 c++ xcode boost boost-log boost-logging

我有一个在 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

预编译 header test_prefix.pch:

//
// Prefix header for all source files in project
//

#include <Carbon/Carbon.h>

已经浪费了数小时在 Xcode 中摆弄编译器设置和项目配置,因此欢迎任何反馈!

最佳答案

在您的前缀 header 中包含 Carbon/Carbon.h 之前,您可能需要#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0。参见 https://svn.boost.org/trac/boost/ticket/6219获取更多信息。

关于c++ - 使用 Xcode 预编译 header 时 boost.log 中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21414556/

相关文章:

c++ - rtree 是可索引断言

c++ - boost cpp 和 Visual Studio 2015

c++ - Boost Asio SSL Stream lowest_layer() 和 next_layer() 之间的区别

c++ - SO_RCVTIME和SO_RCVTIMEO不影响Boost.Asio操作

ios - 嵌入式二进制文件未使用相同的证书签名

ios - 带有标题和图像的 UIButton

xcode - 在 iOS5 中将自定义 Retina 图像添加到 TabBar

C++ "Virtual functions handling on multiple base classes"

c++ - 变量打印为 nan 或 inf 而不是实际值

c++ - 如何检测分配给 size_t 的负数?