Skip to content

Commit 20cb742

Browse files
authored
Fix: Compilation errors in Qt environment (#706)
- prevent redefining NOMINMAX - rename slots function because of naming conflict - explicitly call CreateFileA for char* parameter
1 parent dec24b8 commit 20cb742

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/usearch/index.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272
// OS-specific includes
7373
#if defined(USEARCH_DEFINED_WINDOWS)
7474
#define _USE_MATH_DEFINES
75+
#ifndef NOMINMAX
7576
#define NOMINMAX
77+
#endif
7678
#include <Windows.h>
7779
#include <sys/stat.h> // `fstat` for file size
7880
#undef NOMINMAX
@@ -500,7 +502,7 @@ template <typename allocator_at = std::allocator<byte_t>> class bitset_gt {
500502

501503
static constexpr std::size_t bits_per_slot() { return sizeof(compressed_slot_t) * CHAR_BIT; }
502504
static constexpr compressed_slot_t bits_mask() { return sizeof(compressed_slot_t) * CHAR_BIT - 1; }
503-
static constexpr std::size_t slots(std::size_t bits) { return divide_round_up<bits_per_slot()>(bits); }
505+
static constexpr std::size_t bits_slots(std::size_t bits) { return divide_round_up<bits_per_slot()>(bits); }
504506

505507
compressed_slot_t* slots_{};
506508
/// @brief Number of slots.
@@ -524,8 +526,8 @@ template <typename allocator_at = std::allocator<byte_t>> class bitset_gt {
524526
}
525527

526528
bitset_gt(std::size_t capacity) noexcept
527-
: slots_((compressed_slot_t*)allocator_t{}.allocate(slots(capacity) * sizeof(compressed_slot_t))),
528-
count_(slots_ ? slots(capacity) : 0u) {
529+
: slots_((compressed_slot_t*)allocator_t{}.allocate(bits_slots(capacity) * sizeof(compressed_slot_t))),
530+
count_(slots_ ? bits_slots(capacity) : 0u) {
529531
clear();
530532
}
531533

@@ -1778,7 +1780,7 @@ class memory_mapped_file_t {
17781780
#if defined(USEARCH_DEFINED_WINDOWS)
17791781

17801782
HANDLE file_handle =
1781-
CreateFile(path_, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
1783+
CreateFileA(path_, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
17821784
if (file_handle == INVALID_HANDLE_VALUE)
17831785
return result.failed("Opening file failed!");
17841786

0 commit comments

Comments
 (0)