Skip to content

Commit 096cc82

Browse files
committed
Disable warnings on boost when using gcc8.
Add DIAGNOSTIC_PUSH DIAGNOSTIC_POP and DISABLE_WARNING macros.
1 parent 12fe46a commit 096cc82

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

driver/mysql_prepared_statement.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@
3535

3636
#include <iostream>
3737
#include <sstream>
38+
#include "mysql_util.h"
39+
#ifdef GCC
40+
#if defined __GNUC__ || __GNUC__ >= 8
41+
DISABLE_WARNING(-Wparentheses)
3842
#include <boost/variant.hpp>
3943
#include <boost/scoped_array.hpp>
40-
44+
DIAGNOSTIC_POP
45+
#endif
4146
#include <cppconn/exception.h>
42-
#include "mysql_util.h"
4347
#include "mysql_connection.h"
4448
#include "mysql_statement.h"
4549
#include "mysql_prepared_statement.h"

driver/mysql_util.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,42 @@
118118
(((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
119119
32))
120120

121+
/*
122+
Macros used to disable warnings for fragments of code.
123+
*/
124+
125+
#if defined __GNUC__ || defined __clang__
126+
127+
#define PRAGMA(X) _Pragma(#X)
128+
#define DISABLE_WARNING(W) PRAGMA(GCC diagnostic ignored #W)
129+
130+
#if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
131+
#define DIAGNOSTIC_PUSH PRAGMA(GCC diagnostic push)
132+
#define DIAGNOSTIC_POP PRAGMA(GCC diagnostic pop)
133+
#else
134+
#define DIAGNOSTIC_PUSH
135+
#define DIAGNOSTIC_POP
136+
#endif
137+
138+
#elif defined _MSC_VER
139+
140+
141+
#define PRAGMA(X) __pragma(X)
142+
#define DISABLE_WARNING(W) PRAGMA(warning (disable:W))
143+
144+
#define DIAGNOSTIC_PUSH PRAGMA(warning (push))
145+
#define DIAGNOSTIC_POP PRAGMA(warning (pop))
146+
147+
#else
148+
149+
#define PRAGMA(X)
150+
#define DISABLE_WARNING(W)
151+
152+
#define DIAGNOSTIC_PUSH
153+
#define DIAGNOSTIC_POP
154+
155+
#endif
156+
121157
namespace sql
122158
{
123159
namespace mysql

0 commit comments

Comments
 (0)