THRIFT-1740 Make C++ library build on OS X and iOS
Patch: Ben Craig
minor modification by Roger Meier


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1410127 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp b/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
index 1eb444b..4fbfc13 100644
--- a/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
@@ -253,8 +253,8 @@
   // Back up one step before writing.
   pos++;
 
-  trans_->write(buf+pos, sizeof(buf) - pos);
-  return sizeof(buf) - pos;
+  trans_->write(buf+pos, static_cast<uint32_t>(sizeof(buf) - pos));
+  return static_cast<uint32_t>(sizeof(buf) - pos);
 }
 
 
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h
index 09ce7c4..d6ecc0f 100644
--- a/lib/cpp/src/thrift/protocol/TProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TProtocol.h
@@ -133,8 +133,8 @@
 #  define ntohll(n) ( _byteswap_uint64((uint64_t)n) )
 #  define htonll(n) ( _byteswap_uint64((uint64_t)n) )
 # else /* Not GNUC/GLIBC or MSVC */
-#  define ntohll(n) ( (((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32) )
-#  define htonll(n) ( (((uint64_t)htonl(n)) << 32) + htonl(n >> 32) )
+#  define ntohll(n) ( (((uint64_t)ntohl((uint32_t)n)) << 32) + ntohl((uint32_t)(n >> 32)) )
+#  define htonll(n) ( (((uint64_t)htonl((uint32_t)n)) << 32) + htonl((uint32_t)(n >> 32)) )
 # endif /* GNUC/GLIBC or MSVC or something else */
 #else /* __THRIFT_BYTE_ORDER */
 # error "Can't define htonll or ntohll!"