From 02c22b850bc66eaf2d431b18cd7f682514079b4b Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 4 Feb 2015 11:08:26 -0500 Subject: [PATCH] fixed compilation bug for boost < 1.49 and boost 1.49 with gcc 4.7 --- I2PControl.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/I2PControl.cpp b/I2PControl.cpp index 913f823c..be32be41 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -1,11 +1,15 @@ -#include "I2PControl.h" +// There is bug in boost 1.49 with gcc 4.7 coming with Debian Wheezy +#define GCC47_BOOST149 ((BOOST_VERSION == 104900) && (__GNUC__ != 4) && (__GNUC_MINOR__ != 7)) +#include "I2PControl.h" #include #include #include #include #include +#if !GCC47_BOOST149 #include +#endif #include "Log.h" #include "NetDb.h" #include "RouterContext.h" @@ -111,7 +115,12 @@ namespace client void I2PControlService::ReadRequest (std::shared_ptr socket) { auto request = std::make_shared(); - socket->async_read_some (boost::asio::buffer (*request), + socket->async_read_some ( +#if BOOST_VERSION >= 104900 + boost::asio::buffer (*request), +#else + boost::asio::buffer (request->data (), request->size ()), +#endif std::bind(&I2PControlService::HandleRequestReceived, this, std::placeholders::_1, std::placeholders::_2, socket, request)); } @@ -142,8 +151,12 @@ namespace client return; // TODO: } } +#if GCC47_BOOST149 + LogPrint (eLogError, "json_read is not supported due bug in boost 1.49 with gcc 4.7"); +#else boost::property_tree::ptree pt; boost::property_tree::read_json (ss, pt); + std::string method = pt.get(I2P_CONTROL_PROPERTY_METHOD); auto it = m_MethodHandlers.find (method); if (it != m_MethodHandlers.end ()) @@ -161,6 +174,7 @@ namespace client } else LogPrint (eLogWarning, "Unknown I2PControl method ", method); +#endif } catch (std::exception& ex) { @@ -187,7 +201,11 @@ namespace client pt.put ("jsonrpc", "2.0"); std::ostringstream ss; +#if GCC47_BOOST149 + LogPrint (eLogError, "json_write is not supported due bug in boost 1.49 with gcc 4.7"); +#else boost::property_tree::write_json (ss, pt, false); +#endif size_t len = ss.str ().length (), offset = 0; if (isHtml) {