Skip to content

Commit 178e876

Browse files
committed
Fix C++17 usage warnings.
Windows doesn't define correctly __cplusplus macro...
1 parent 3387369 commit 178e876

File tree

6 files changed

+14
-36
lines changed

6 files changed

+14
-36
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ if(NOT SHOW_JDBC_WARNINGS)
219219

220220
endif()
221221

222+
222223
############################################################################
223224
#
224225
# Main components and connector library target.

cppconn/exception.h

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
namespace sql
4242
{
4343

44-
#if (__cplusplus < 201103L)
45-
#define MEMORY_ALLOC_OPERATORS(Class) \
46-
void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \
47-
void* operator new(size_t, void*) throw(); \
48-
void* operator new(size_t, const std::nothrow_t&) throw(); \
49-
void* operator new[](size_t) throw (std::bad_alloc); \
50-
void* operator new[](size_t, void*) throw(); \
51-
void* operator new[](size_t, const std::nothrow_t&) throw(); \
52-
void* operator new(size_t N, std::allocator<Class>&);
53-
#else
5444
#define MEMORY_ALLOC_OPERATORS(Class) \
5545
void* operator new(size_t size){ return ::operator new(size); } \
5646
void* operator new(size_t, void*) noexcept; \
@@ -60,20 +50,9 @@ namespace sql
6050
void* operator new[](size_t, const std::nothrow_t&) noexcept; \
6151
void* operator new(size_t N, std::allocator<Class>&);
6252

63-
#endif
64-
#ifdef _WIN32
65-
#pragma warning (disable : 4290)
66-
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
67-
6853

69-
#pragma warning(push)
70-
#pragma warning(disable: 4275)
71-
#endif
72-
class CPPCONN_PUBLIC_FUNC SQLException : public std::runtime_error
54+
class SQLException : public std::runtime_error
7355
{
74-
#ifdef _WIN32
75-
#pragma warning(pop)
76-
#endif
7756
protected:
7857
const std::string sql_state;
7958
const int errNo;
@@ -109,38 +88,38 @@ class CPPCONN_PUBLIC_FUNC SQLException : public std::runtime_error
10988
return errNo;
11089
}
11190

112-
virtual ~SQLException() throw () {};
91+
virtual ~SQLException() noexcept {};
11392

11493
protected:
11594
MEMORY_ALLOC_OPERATORS(SQLException)
11695
};
11796

118-
struct CPPCONN_PUBLIC_FUNC MethodNotImplementedException : public SQLException
97+
struct MethodNotImplementedException : public SQLException
11998
{
12099
MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
121100
MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {}
122101
};
123102

124-
struct CPPCONN_PUBLIC_FUNC InvalidArgumentException : public SQLException
103+
struct InvalidArgumentException : public SQLException
125104
{
126105
InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
127106
InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {}
128107
};
129108

130-
struct CPPCONN_PUBLIC_FUNC InvalidInstanceException : public SQLException
109+
struct InvalidInstanceException : public SQLException
131110
{
132111
InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
133112
InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {}
134113
};
135114

136115

137-
struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException
116+
struct NonScrollableException : public SQLException
138117
{
139118
NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
140119
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
141120
};
142121

143-
struct CPPCONN_PUBLIC_FUNC SQLUnsupportedOptionException : public SQLException
122+
struct SQLUnsupportedOptionException : public SQLException
144123
{
145124
SQLUnsupportedOptionException(const SQLUnsupportedOptionException& e, const std::string conn_option) :
146125
SQLException(e.what(), e.sql_state, e.errNo),
@@ -157,7 +136,7 @@ struct CPPCONN_PUBLIC_FUNC SQLUnsupportedOptionException : public SQLException
157136
return option.c_str();
158137
}
159138

160-
~SQLUnsupportedOptionException() throw () {};
139+
~SQLUnsupportedOptionException() noexcept {};
161140
protected:
162141
const std::string option;
163142
};

driver/mysql_connection.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,7 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
657657
throw sql::InvalidArgumentException("Wrong type passed for port expected int");
658658
}
659659
if (p_i) {
660-
for(auto &h : uri)
661-
{
662-
uri.setDefaultPort(*p_i);
663-
}
660+
uri.setDefaultPort(*p_i);
664661
} else {
665662
throw sql::InvalidArgumentException("No long long value passed for port");
666663
}

driver/mysql_debug.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ MySQL_DebugLogger::MySQL_DebugLogger()
9191
/* {{{ MySQL_DebugLogger::~MySQL_DebugLogger() -I- */
9292
MySQL_DebugLogger::~MySQL_DebugLogger()
9393
{
94-
callStack.empty();
94+
while(!callStack.empty())
95+
callStack.pop();
9596
}
9697
/* }}} */
9798

examples/examples.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct _test_data {
7878
int id;
7979
const char* label;
8080
};
81-
static _test_data test_data[EXAMPLE_NUM_TEST_ROWS] = {
81+
_test_data test_data[EXAMPLE_NUM_TEST_ROWS] = {
8282
{1, ""}, {2, "a"}, {3, "b"}, {4, "c"},
8383
};
8484

test/framework/test_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TestsRunner::TestsRunner()
4949

5050
bool TestsRunner::runTests()
5151
{
52-
TestSuiteNames.empty();
52+
TestSuiteNames.clear();
5353

5454
TestSuiteFactory::theInstance().getTestsList( TestSuiteNames );
5555

0 commit comments

Comments
 (0)