Skip to content

Conversation

@maxwbuckley
Copy link

Summary

  • Enable strict compiler warnings and fix ~220+ warnings across the codebase
  • Add HNSWLIB_WERROR CMake option to treat warnings as errors
  • Ensure all library headers, examples, and tests compile cleanly with strict flags

Changes

Library headers:

  • Convert C-style casts to C++ casts (static_cast, reinterpret_cast, const_cast)
  • Fix const correctness in distance functions and data pointers
  • Mark unused parameters with /*name*/ syntax
  • Add missing override keywords on virtual functions
  • Fix shadow variable warnings
  • Fix sign comparison warnings (int vs size_t)
  • Add HNSWLIB_MAYBE_UNUSED macro for conditionally-used SIMD functions
  • Fix member initializer order in visited_list_pool.h

Examples and tests:

  • Fix sign comparison warnings in loops
  • Mark unused lambda parameters
  • Fix shadow variables
  • Add missing override keywords

Build infrastructure:

  • Update CMakeLists.txt with proper warning flags for GCC/Clang/MSVC
  • Add HNSWLIB_WERROR option to treat warnings as errors

Note

The .github/workflows/build.yml change to enable -DHNSWLIB_WERROR=ON in CI could not be included in this PR due to GitHub token permissions. Maintainers may want to add this line to the build step:

cmake .. -DHNSWLIB_WERROR=ON

Test plan

  • All C++ tests pass (searchKnnCloserFirst_test, epsilon_search_test, searchKnnWithFilter_test, multivector_search_test, multiThread_replace_test, multiThreadLoad_test)
  • All Python binding tests pass
  • Build succeeds with -DHNSWLIB_WERROR=ON (warnings as errors)

🤖 Generated with Claude Code

Enable strict compiler warnings and fix all issues found:

Library headers:
- Convert C-style casts to C++ casts (static_cast, reinterpret_cast, const_cast)
- Fix const correctness in distance functions and data pointers
- Mark unused parameters with /*name*/ syntax
- Add missing override keywords on virtual functions
- Fix shadow variable warnings
- Fix sign comparison warnings (int vs size_t)
- Add HNSWLIB_MAYBE_UNUSED macro for conditionally-used SIMD functions
- Fix member initializer order in visited_list_pool.h

Examples and tests:
- Fix sign comparison warnings in loops
- Mark unused lambda parameters
- Fix shadow variables
- Add missing override keywords

Build infrastructure:
- Update CMakeLists.txt with proper warning flags for GCC/Clang/MSVC
- Add HNSWLIB_WERROR option to treat warnings as errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant