0

I've got a pretty minimal sample project for boost.log running on Xcode 5, which goes like this:

#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;
}

Now everything runs fine with a command line project.

However as soon as I use the snipped in a real-world project with the default Xcode precompiled header file I'm getting compiler errors in boost/type_traits/detail/has_binary_operator.hpp and boost/lexical_cast.hpp.

Precompiled header test_prefix.pch:

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

#include <Carbon/Carbon.h>

Already wasted hours fiddling with compiler settings and project configuration in Xcode so any feedback is appreciated!

Jay
  • 6,572
  • 3
  • 37
  • 65
  • Why don't you show the error you are getting? Also, is there any reason to believe it's due to the PCH settings? Have you seen the problem go away without that in the same project? – sehe Jan 29 '14 at 08:36
  • @sehe Yep, I can '*toggle*' the error by including the pch.. in multiple projects that work fine otherwise (i.e. no precompiled header) – Jay Jan 29 '14 at 16:15

1 Answers1

2

You likely need to #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 prior to including Carbon/Carbon.h in your prefix header. See https://svn.boost.org/trac/boost/ticket/6219 for more information.

bdash
  • 18,110
  • 1
  • 59
  • 91
  • @bdash Awesome. Now, out of curiosity: how did you figure this one out? – sehe Jan 29 '14 at 20:59
  • A Google search for "has_binary_operator.hpp Carbon.h" gives the Trac ticket I linked to as the first result. – bdash Jan 30 '14 at 21:02