Skip to content

Commit ac24564

Browse files
authored
CXX-3088 fix build with GCC 4.8.5 (#1194)
* declare `npos` as `constexpr` to fix old gcc Resolves error: "redeclaration [...] differs in 'constexpr'" * use C++11 syntax for user defined literals to fix old gcc Resolves error: "missing space between '""' and suffix identifier" * add test with gcc 4.8.5 * do not add `-Wno-expansion-to-defined` for RHEL-7 gcc 4.8.5 does not recognize. * add `-Wno-unused-parameter` on RHEL 7 compile Resolves warnings (causing errors) addressed in CDRIVER-5673. Upgrading C driver to get fix results in test failures due to removal of "rangePreview" algorithm.
1 parent 0d649bf commit ac24564

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

.evergreen/compile.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ darwin*)
148148
;;
149149
linux*)
150150
cc_flags+=("${cc_flags_init[@]}")
151-
cxx_flags+=("${cxx_flags_init[@]}" -Wno-expansion-to-defined -Wno-missing-field-initializers)
151+
cxx_flags+=("${cxx_flags_init[@]}" -Wno-missing-field-initializers)
152+
153+
if [[ "${distro_id:?}" != rhel7* ]]; then
154+
cxx_flags+=("-Wno-expansion-to-defined")
155+
else
156+
cxx_flags+=("-Wno-unused-parameter") # TODO: remove once C driver is upgraded to include fix of CDRIVER-5673.
157+
fi
152158
;;
153159
*)
154160
echo "unrecognized operating system ${OSTYPE:?}" 1>&2

.mci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,3 +2209,13 @@ buildvariants:
22092209
display_name: silk
22102210
tasks:
22112211
- name: .silk
2212+
2213+
- name: rhel79-compile
2214+
display_name: "RHEL 7.9 (gcc 4.8.5)"
2215+
expansions:
2216+
build_type: "Release"
2217+
BSONCXX_POLYFILL: impls
2218+
run_on:
2219+
- rhel79-small
2220+
tasks:
2221+
- name: compile_without_tests

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ BSONCXX_API document::value BSONCXX_CALL from_json(stdx::string_view json);
8282
///
8383
/// @throws bsoncxx::v_noabi::exception with error details if the conversion failed.
8484
///
85-
BSONCXX_API document::value BSONCXX_CALL operator""_bson(const char* json, size_t len);
85+
BSONCXX_API document::value BSONCXX_CALL operator"" _bson(const char* json, size_t len);
8686

8787
} // namespace v_noabi
8888
} // namespace bsoncxx
@@ -92,7 +92,7 @@ namespace bsoncxx {
9292
using ::bsoncxx::v_noabi::from_json;
9393
using ::bsoncxx::v_noabi::to_json;
9494

95-
using ::bsoncxx::v_noabi::operator""_bson;
95+
using ::bsoncxx::v_noabi::operator"" _bson;
9696

9797
} // namespace bsoncxx
9898

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail::
438438
// Required to define this here for compatibility with C++14 and older. Can be removed in C++17 or
439439
// newer.
440440
template <typename C, typename Tr>
441-
const std::size_t basic_string_view<C, Tr>::npos;
441+
constexpr std::size_t basic_string_view<C, Tr>::npos;
442442

443443
using string_view = basic_string_view<char>;
444444

src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ document::value BSONCXX_CALL from_json(stdx::string_view json) {
9999
return document::value{buf, length, bson_free_deleter};
100100
}
101101

102-
document::value BSONCXX_CALL operator""_bson(const char* str, size_t len) {
102+
document::value BSONCXX_CALL operator"" _bson(const char* str, size_t len) {
103103
return from_json(stdx::string_view{str, len});
104104
}
105105

0 commit comments

Comments
 (0)