Skip to content

Instantly share code, notes, and snippets.

@kumarjatin
Created July 17, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumarjatin/4b8fc3389696b96b23d9 to your computer and use it in GitHub Desktop.
Save kumarjatin/4b8fc3389696b96b23d9 to your computer and use it in GitHub Desktop.
Patch for thrift-0.9.1 to compile it without "-std=c++11" flag and other patches on mac osx 10.10.3.
diff --git a/lib/cpp/src/thrift/cxxfunctional.h b/lib/cpp/src/thrift/cxxfunctional.h
index c24b91b..d9921d7 100644
--- a/lib/cpp/src/thrift/cxxfunctional.h
+++ b/lib/cpp/src/thrift/cxxfunctional.h
@@ -86,19 +86,19 @@
}}} // apache::thrift::stdcxx
#elif _THRIFT_USING_CLANG_LIBCXX
- #include <functional>
+ #include <boost/tr1/functional.hpp>
namespace apache { namespace thrift { namespace stdcxx {
- using ::std::function;
- using ::std::bind;
+ using ::std::tr1::function;
+ using ::std::tr1::bind;
namespace placeholders {
- using ::std::placeholders::_1;
- using ::std::placeholders::_2;
- using ::std::placeholders::_3;
- using ::std::placeholders::_4;
- using ::std::placeholders::_5;
- using ::std::placeholders::_6;
+ using ::std::tr1::placeholders::_1;
+ using ::std::tr1::placeholders::_2;
+ using ::std::tr1::placeholders::_3;
+ using ::std::tr1::placeholders::_4;
+ using ::std::tr1::placeholders::_5;
+ using ::std::tr1::placeholders::_6;
} // apache::thrift::stdcxx::placeholders
}}} // apache::thrift::stdcxx
diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp
index ba71caa..b91df2e 100644
--- a/tutorial/cpp/CppClient.cpp
+++ b/tutorial/cpp/CppClient.cpp
@@ -38,9 +38,9 @@ using namespace shared;
using namespace boost;
int main(int argc, char** argv) {
- shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
- shared_ptr<TTransport> transport(new TBufferedTransport(socket));
- shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+ boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
+ boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
+ boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
CalculatorClient client(protocol);
try {
diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp
index d0dbad9..db5a9b0 100644
--- a/tutorial/cpp/CppServer.cpp
+++ b/tutorial/cpp/CppServer.cpp
@@ -113,11 +113,11 @@ protected:
int main(int argc, char **argv) {
- shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
- shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
- shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
- shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
- shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
+ boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+ boost::shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
+ boost::shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
+ boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
+ boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
TSimpleServer server(processor,
serverTransport,
@kumarjatin
Copy link
Author

Thrift-0.9.1 doesn't compile on MAC as such because clang compiler doesn't expose std::bind without enabling -std=c++11 flag. I had a requirement to compile it without this flag as enabling this breaks some other component of my tool and also you need to make 3-4 other patches to compile it with -std=c++11 flag.

So, I took a different approach, used tr1 support from my boost-1.58.0 library. After applying this patch on fresh thrift-0.9.1, it compiles fine on mac without enabling c++11 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment