asg017 / sqlite-vec

A vector search SQLite extension that runs anywhere!
Apache License 2.0
4.26k stars 135 forks source link

PORTABLE_ALIGN<x> should use __declspec on MSVC #137

Open Agritite opened 5 days ago

Agritite commented 5 days ago

https://github.com/asg017/sqlite-vec/blob/ee3654701f7b8efe4802ff1caed24514f43443dd/sqlite-vec.c#L119-L122

Currently this causes SQLITE_VEC_ENABLE_AVX to fail with MSVC

prolly should be something like:

#ifdef SQLITE_VEC_ENABLE_AVX
#include <immintrin.h>
#ifdef _MSC_VER // Visual Studio
#define PORTABLE_ALIGN32 __declspec(align(32))
#define PORTABLE_ALIGN64 __declspec(align(64))
#else
#define PORTABLE_ALIGN32 __attribute__((aligned(32)))
#define PORTABLE_ALIGN64 __attribute__((aligned(64)))
#endif

(this compiles on my computer with MSVC, and seems to function correctly with my dataset)

Or more elifdefs for other compilers I'm not aware of

I can submit PR if this fix is acceptable, or suggestions provided