THRIFT-3873: fix various compiler warnings and overflow errors
THRIFT-3847: change VERSION to PACKAGE_VERSION to avoid conflicts with third party or OS headers
This closes #1128
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index c16d045..da20b89 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -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
@@ -17,8 +17,6 @@
* under the License.
*/
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
#include <limits>
#include <locale>
#include <ios>
@@ -35,6 +33,13 @@
#include <thrift/async/TEvhttpClientChannel.h>
#include <thrift/server/TNonblockingServer.h> // <event.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <boost/shared_ptr.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
@@ -355,6 +360,10 @@
}
try {
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 4566 )
+#endif
string str(
"}{Afrikaans, Alemannisch, Aragonés, العربية, مصرى, "
"Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, "
@@ -381,6 +390,9 @@
"Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, "
"Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, "
"Bân-lâm-gú, 粵語");
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
cout << "testString(" << str << ") = " << flush;
testClient.testString(s, str);
cout << s << endl;
@@ -457,10 +469,10 @@
BASETYPE_IDENTITY_TEST(testI64, (int64_t)-1);
BASETYPE_IDENTITY_TEST(testI64, (int64_t)7000000000000000123LL);
BASETYPE_IDENTITY_TEST(testI64, (int64_t)-7000000000000000123LL);
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(2LL, 32));
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(2LL, 32));
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(2LL, 32) + 1);
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(2LL, 32) - 1);
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(static_cast<double>(2LL), 32));
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(static_cast<double>(2LL), 32));
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(static_cast<double>(2LL), 32) + 1);
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(static_cast<double>(2LL), 32) - 1);
BASETYPE_IDENTITY_TEST(testI64, numeric_limits<int64_t>::max());
BASETYPE_IDENTITY_TEST(testI64, numeric_limits<int64_t>::min());
@@ -472,19 +484,19 @@
BASETYPE_IDENTITY_TEST(testDouble, -1.0);
BASETYPE_IDENTITY_TEST(testDouble, -5.2098523);
BASETYPE_IDENTITY_TEST(testDouble, -0.000341012439638598279);
- BASETYPE_IDENTITY_TEST(testDouble, pow(2, 32));
- BASETYPE_IDENTITY_TEST(testDouble, pow(2, 32) + 1);
- BASETYPE_IDENTITY_TEST(testDouble, pow(2, 53) - 1);
- BASETYPE_IDENTITY_TEST(testDouble, -pow(2, 32));
- BASETYPE_IDENTITY_TEST(testDouble, -pow(2, 32) - 1);
- BASETYPE_IDENTITY_TEST(testDouble, -pow(2, 53) + 1);
+ BASETYPE_IDENTITY_TEST(testDouble, pow(static_cast<double>(2), 32));
+ BASETYPE_IDENTITY_TEST(testDouble, pow(static_cast<double>(2), 32) + 1);
+ BASETYPE_IDENTITY_TEST(testDouble, pow(static_cast<double>(2), 53) - 1);
+ BASETYPE_IDENTITY_TEST(testDouble, -pow(static_cast<double>(2), 32));
+ BASETYPE_IDENTITY_TEST(testDouble, -pow(static_cast<double>(2), 32) - 1);
+ BASETYPE_IDENTITY_TEST(testDouble, -pow(static_cast<double>(2), 53) + 1);
try {
- double expected = pow(10, 307);
+ double expected = pow(static_cast<double>(10), 307);
cout << "testDouble(" << expected << ") = " << flush;
double actual = testClient.testDouble(expected);
cout << "(" << actual << ")" << endl;
- if (expected - actual > pow(10, 292)) {
+ if (expected - actual > pow(static_cast<double>(10), 292)) {
cout << "*** FAILED ***" << endl
<< "Expected: " << expected << " but got: " << actual << endl;
}
@@ -496,11 +508,11 @@
}
try {
- double expected = pow(10, -292);
+ double expected = pow(static_cast<double>(10), -292);
cout << "testDouble(" << expected << ") = " << flush;
double actual = testClient.testDouble(expected);
cout << "(" << actual << ")" << endl;
- if (expected - actual > pow(10, -307)) {
+ if (expected - actual > pow(static_cast<double>(10), -307)) {
cout << "*** FAILED ***" << endl
<< "Expected: " << expected << " but got: " << actual << endl;
}
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index b437860..b86b34c 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -17,9 +17,6 @@
* under the License.
*/
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
-
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/protocol/TBinaryProtocol.h>
@@ -41,6 +38,13 @@
#include <thrift/transport/TTransportUtils.h>
#include "ThriftTest.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <iostream>
#include <stdexcept>
#include <sstream>