11diff --git a/src/common/src/common-bson-dsl-private.h b/src/common/src/common-bson-dsl-private.h
2- index b6cb7a2705..c2cb0bcaf2 100644
2+ index 748ba54046..67a6a4f194 100644
33--- a/src/common/src/common-bson-dsl-private.h
44+++ b/src/common/src/common-bson-dsl-private.h
55@@ -31,6 +31,13 @@ enum {
6- BSON_IF_WINDOWS (__declspec (selectany)) \
7- BSON_IF_POSIX (__attribute__ ((weak)))
6+ BSON_IF_WINDOWS(__declspec(selectany)) \
7+ BSON_IF_POSIX(__attribute__((weak)))
88
99+ #if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
1010+ // Using GCC < 4.6
1111+ // Do not define `GCC diagnostic` pragma for GCC < 4.6.
12- + #define _bsonDSL_disableWarnings() ((void) 0)
13- + #define _bsonDSL_restoreWarnings() ((void) 0)
12+ + #define _bsonDSL_disableWarnings() ((void)0)
13+ + #define _bsonDSL_restoreWarnings() ((void)0)
1414+ #else
1515+ // Not using GCC < 4.6
1616 #ifdef __GNUC__
1717 // GCC has a bug handling pragma statements that disable warnings within complex
1818 // nested macro expansions. If we're GCC, just disable -Wshadow outright:
19- @@ -50,7 +57,7 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
20- mlib_diagnostic_pop (); \
19+ @@ -50,7 +57,7 @@ BSON_IF_GNU_LIKE(_Pragma("GCC diagnostic ignored \"-Wshadow\""))
20+ mlib_diagnostic_pop(); \
2121 } else \
22- ((void) 0)
22+ ((void)0)
2323-
2424+ #endif
2525 /**
2626 * @brief Parse the given BSON document.
2727 *
28+ diff --git a/src/common/src/common-macros-private.h b/src/common/src/common-macros-private.h
29+ index 068b09470f..b5c94c5c9d 100644
30+ --- a/src/common/src/common-macros-private.h
31+ +++ b/src/common/src/common-macros-private.h
32+ @@ -97,7 +97,13 @@
33+ #endif
34+
35+ // Disable the -Wcast-qual warning
36+ - #if defined(__GNUC__)
37+ + #if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
38+ + // Using GCC < 4.6
39+ + // Do not define `GCC diagnostic` pragma for GCC < 4.6.
40+ + #define MC_DISABLE_CAST_QUAL_WARNING_BEGIN
41+ + #define MC_DISABLE_CAST_QUAL_WARNING_END
42+ + #elif defined(__GNUC__)
43+ + // Not using GCC < 4.6
44+ #define MC_DISABLE_CAST_QUAL_WARNING_BEGIN MC_PRAGMA_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
45+ #define MC_DISABLE_CAST_QUAL_WARNING_END MC_PRAGMA_DIAGNOSTIC_POP
46+ #elif defined(__clang__)
2847diff --git a/src/common/src/mlib/config.h b/src/common/src/mlib/config.h
29- index 6a1e45275b..797f278250 100644
48+ index a95f917efb..d1494797cd 100644
3049--- a/src/common/src/mlib/config.h
3150+++ b/src/common/src/mlib/config.h
32- @@ -175 ,7 +175 ,13 @@
51+ @@ -204 ,7 +204 ,13 @@
3352 * @brief Expands to `noexcept` when compiled as C++, otherwise expands to
3453 * nothing
3554 */
@@ -38,25 +57,25 @@ index 6a1e45275b..797f278250 100644
3857+ // Don't define this expansion for the older gcc/g++
3958+ #define mlib_noexcept
4059+ #else
41- #define mlib_noexcept MLIB_IF_CXX (noexcept)
60+ #define mlib_noexcept MLIB_IF_CXX(noexcept)
4261+ #endif
4362
4463 #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
4564 #define mlib_is_little_endian() (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
46- @@ -253 ,15 +259 ,29 @@
65+ @@ -282 ,15 +288 ,29 @@
4766
48- #define MLIB_FUNC MLIB_IF_GNU_LIKE (__func__) MLIB_IF_MSVC (__FUNCTION__)
67+ #define MLIB_FUNC MLIB_IF_GNU_LIKE(__func__) MLIB_IF_MSVC(__FUNCTION__)
4968
5069+ #if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
5170+ // Using GCC < 4.6
5271+ // Do not define `GCC diagnostic` pragma for GCC < 4.6.
5372+ #define mlib_diagnostic_push()
5473+ #else
5574+ // Not using GCC < 4.6
56- #define mlib_diagnostic_push() \
57- MLIB_IF_GNU_LIKE (mlib_pragma (GCC diagnostic push);) \
58- MLIB_IF_MSVC (mlib_pragma (warning (push));) \
59- mlib_static_assert (1, "")
75+ #define mlib_diagnostic_push() \
76+ MLIB_IF_GNU_LIKE(mlib_pragma(GCC diagnostic push);) \
77+ MLIB_IF_MSVC(mlib_pragma(warning(push));) \
78+ mlib_static_assert(1, "")
6079+ #endif
6180
6281+ #if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
@@ -65,15 +84,15 @@ index 6a1e45275b..797f278250 100644
6584+ #define mlib_diagnostic_pop()
6685+ #else
6786+ // Not using GCC < 4.6
68- #define mlib_diagnostic_pop() \
69- MLIB_IF_GNU_LIKE (mlib_pragma (GCC diagnostic pop);) \
70- MLIB_IF_MSVC (mlib_pragma (warning (pop));) \
71- mlib_static_assert (1, "")
87+ #define mlib_diagnostic_pop() \
88+ MLIB_IF_GNU_LIKE(mlib_pragma(GCC diagnostic pop);) \
89+ MLIB_IF_MSVC(mlib_pragma(warning(pop));) \
90+ mlib_static_assert(1, "")
7291+ #endif
7392
74- #define mlib_gcc_warning_disable(Warning) \
75- MLIB_IF_GCC (mlib_pragma (GCC diagnostic ignored Warning);) \
76- @@ -315 ,9 +335 ,15 @@
93+ #define mlib_gcc_warning_disable(Warning) \
94+ MLIB_IF_GCC(mlib_pragma(GCC diagnostic ignored Warning);) \
95+ @@ -344 ,9 +364 ,15 @@
7796 /**
7897 * @brief Emit a _Pragma that will disable warnings about the use of deprecated entities.
7998 */
@@ -82,9 +101,9 @@ index 6a1e45275b..797f278250 100644
82101+ #define mlib_disable_deprecation_warnings()
83102+ #else
84103+ // Not using GCC < 4.6
85- #define mlib_disable_deprecation_warnings() \
86- mlib_gnu_warning_disable ("-Wdeprecated-declarations"); \
87- mlib_msvc_warning (disable : 4996)
104+ #define mlib_disable_deprecation_warnings() \
105+ mlib_gnu_warning_disable("-Wdeprecated-declarations"); \
106+ mlib_msvc_warning(disable : 4996)
88107+ #endif
89108
90109 /**
0 commit comments