From e8cb1a07c7778e48e1f2f4fa4f87b504d80a1ca6 Mon Sep 17 00:00:00 2001 From: Aaron Paterson Date: Fri, 23 Oct 2026 02:30:28 -0500 Subject: [PATCH] Give SQLITE_VEC_API no __attribute__ under MSVC in static builds With -DSQLITE_VEC_STATIC the template defines SQLITE_VEC_API as __attribute__((visibility("default"))) on every compiler. MSVC has no __attribute__, so a static build with it stops at the header's declaration of sqlite3_vec_init(); with MSVC 19.44 on windows-2022: cl /c /W4 /Ivendor/ /O2 /DSQLITE_CORE /DSQLITE_VEC_STATIC sqlite-vec.c sqlite-vec.h(34): error C2143: syntax error: missing ')' before '(' sqlite-vec.h(34): error C2091: function returns function The loadable build, which CI compiles with cl.exe, takes the _WIN32 branch and is unaffected. The static branch now applies the attribute only under GCC and Clang outside Windows, the guard asg017/sqlite-vec#340 uses, and defines SQLITE_VEC_API empty otherwise. With GCC and Clang the static objects are byte-identical before and after. sqlite-vec.h regenerates from the template with the next version bump, as it does for the template's other changes. --- sqlite-vec.h.tmpl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlite-vec.h.tmpl b/sqlite-vec.h.tmpl index 702250e6..fe7ba847 100644 --- a/sqlite-vec.h.tmpl +++ b/sqlite-vec.h.tmpl @@ -8,7 +8,11 @@ #endif #ifdef SQLITE_VEC_STATIC - #define SQLITE_VEC_API __attribute__((visibility("default"))) + #if defined(__GNUC__) && !defined(_WIN32) + #define SQLITE_VEC_API __attribute__((visibility("default"))) + #else + #define SQLITE_VEC_API + #endif #else #ifdef _WIN32 #define SQLITE_VEC_API __declspec(dllexport)