THRIFT-4515: fix windows build
Client: cpp
diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
index f443489..8af4b6c 100644
--- a/build/cmake/DefinePlatformSpecifc.cmake
+++ b/build/cmake/DefinePlatformSpecifc.cmake
@@ -90,6 +90,7 @@
 endif()
 
 add_definitions("-D__STDC_FORMAT_MACROS")
+add_definitions("-D__STDC_LIMIT_MACROS")
 
 # WITH_*THREADS selects which threading library to use
 if(WITH_BOOSTTHREADS)
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index 1d2692d..9ac2f84 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -368,7 +368,7 @@
       throw TTransportException(TTransportException::BAD_ARGS,
                                 "Internal buffer size overflow");
     }
-    avail = available_write() + (new_size - bufferSize_);
+    avail = available_write() + (static_cast<uint32_t>(new_size) - bufferSize_);
   }
 
   // Allocate into a new pointer so we don't bork ours if it fails.
@@ -382,7 +382,7 @@
   wBase_ = new_buffer + (wBase_ - buffer_);
   wBound_ = new_buffer + new_size;
   buffer_ = new_buffer;
-  bufferSize_ = new_size;
+  bufferSize_ = static_cast<uint32_t>(new_size);
 }
 
 void TMemoryBuffer::writeSlow(const uint8_t* buf, uint32_t len) {
diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt
index 9b62cc9..261382f 100644
--- a/lib/cpp/test/CMakeLists.txt
+++ b/lib/cpp/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-#
+#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements. See the NOTICE file
 # distributed with this work for additional information
@@ -19,9 +19,6 @@
 
 include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
 
-add_definitions("-D__STDC_FORMAT_MACROS")
-add_definitions("-D__STDC_LIMIT_MACROS")
-
 if (WITH_DYN_LINK_TEST)
     add_definitions( -DBOOST_TEST_DYN_LINK )
 endif()
diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp
index df5099d..fc0ba7f 100644
--- a/lib/cpp/test/concurrency/Tests.cpp
+++ b/lib/cpp/test/concurrency/Tests.cpp
@@ -27,7 +27,7 @@
 
 // The test weight, where 10 is 10 times more threads than baseline
 // and the baseline is optimized for running in valgrind
-static size_t WEIGHT = 10;
+static int WEIGHT = 10;
 
 int main(int argc, char** argv) {
 
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 6b4df7d..b93e5ea 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -114,7 +114,7 @@
   void testBinary(std::string& _return, const std::string& thing) {
     std::ostringstream hexstr;
     hexstr << std::hex << thing;
-    printf("testBinary(%lu: %s)\n", thing.size(), hexstr.str().c_str());
+    printf("testBinary(%lu: %s)\n", safe_numeric_cast<unsigned long>(thing.size()), hexstr.str().c_str());
     _return = thing;
   }
 
@@ -796,7 +796,7 @@
 
 	// THRIFT-4515: this needs to be improved
     while (1) {
-		sleep(1);	// do something other than chew up CPU like crazy
+		  THRIFT_SLEEP_SEC(1);	// do something other than chew up CPU like crazy
     }
 	// NOTREACHED