Skip to content

usearch v2.24.0 fails to compile on Windows MSVC: MAP_FAILED undeclared in index_plugins.hpp #746

@jxoesneon

Description

@jxoesneon

Description

The usearch crate v2.24.0 fails to compile on Windows with MSVC (cl.exe) due to an undefined MAP_FAILED identifier in include/usearch/index_plugins.hpp at line 962.

MAP_FAILED is defined in <sys/mman.h>, which is POSIX-only and does not exist on Windows.

Error

ninclude\usearch/index_plugins.hpp(962): error C3861: 'MAP_FAILED': identifier not found include\usearch/index_plugins.hpp(962): error C2065: 'MAP_FAILED': undeclared identifier n

Affected line

`cpp
if (!new_arena || new_arena == (byte_t*)MAP_FAILED)
return nullptr;
``n

Environment

  • OS: Windows 11
  • Compiler: MSVC 14.44.35207 (Visual Studio 2022 Build Tools)
  • Rust target: x86_64-pc-windows-msvc
  • usearch version: 2.24.0 (from crates.io)

Workaround

Adding the following guard near the top of index_plugins.hpp resolves the issue:
`cpp
#ifndef MAP_FAILED
#define MAP_FAILED ((void*)-1)
#endif
``n

Suggested fix

Add a platform guard for MAP_FAILED in index_plugins.hpp, or conditionally compile the memory_mapping_allocator_gt code path that references it on non-Windows platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions