Skip to content

Commit 00ef6e6

Browse files
authored
Fix build on MacOS with gcc-15 (#870)
1 parent f4b1f1b commit 00ef6e6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

cmake/CompilerOptions.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function(set_project_options target_name)
4242
endif()
4343

4444
if(HAVE_BACKTRACE OR HAVE_DLADDR)
45-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
45+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
46+
AND NOT APPLE
47+
AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
4648
target_compile_options(${target_name} PRIVATE -ggdb3)
4749
endif()
4850
target_compile_definitions(${target_name} PRIVATE -D_GNU_SOURCE=1)

core/transactions/transactions_cleanup.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ parse_mutation_cas(const std::string& cas) -> std::uint64_t
7777
if (cas.empty()) {
7878
return 0;
7979
}
80-
return core::utils::byte_swap(static_cast<std::uint64_t>(std::stoull(cas, nullptr, 16))) /
81-
1000000;
80+
return core::utils::byte_swap(std::stoull(cas, nullptr, 16)) / 1000000;
8281
}
8382

8483
// TODO(CXXCBC-549)

core/utils/byteswap.hxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#pragma once
1919

2020
#include <cstdint>
21+
#include <type_traits>
2122

2223
namespace couchbase::core::utils
2324
{
@@ -46,4 +47,15 @@ byte_swap(std::uint64_t value) -> std::uint64_t
4647
std::uint32_t lo = byte_swap(static_cast<std::uint32_t>(value >> 32));
4748
return (hi << 32) | lo;
4849
}
50+
51+
// when 'unsigned long long' is not the same as 'std::uint64_t'
52+
template<typename Dummy = void>
53+
static constexpr auto
54+
byte_swap(unsigned long long value,
55+
std::enable_if_t<!std::is_same_v<unsigned long long, std::uint64_t>, Dummy>* /* dummy */ =
56+
nullptr) -> std::uint64_t
57+
{
58+
return byte_swap(static_cast<std::uint64_t>(value));
59+
}
60+
4961
} // namespace couchbase::core::utils

0 commit comments

Comments
 (0)