Skip to content

Mark sqlite3_vec_init's pApi unused under SQLITE_CORE - #341

Open
MayCXC wants to merge 1 commit into
asg017:mainfrom
MayCXC:core-unused-api
Open

MayCXC wants to merge 1 commit into
asg017:mainfrom
MayCXC:core-unused-api

Conversation

@MayCXC

@MayCXC MayCXC commented Oct 23, 2026 •

Copy link
Copy Markdown

Compiled with -DSQLITE_CORE, as when sqlite-vec.c is built into SQLite or into an application, sqlite3_vec_init() never reads its pApi parameter: SQLITE_EXTENSION_INIT2() is its only use, and SQLITE_CORE leaves it out. A project that compiles the file into its own binary with -Wall -Wextra gets a warning for it from main, with gcc 14.2 and with clang 19.1:

$ ./scripts/vendor.sh && make sqlite-vec.h
$ gcc -Ivendor -Wall -Wextra -DSQLITE_CORE -DSQLITE_VEC_STATIC -c sqlite-vec.c -o vec.o
...
sqlite-vec.c:10633:65: warning: unused parameter 'pApi' [-Wunused-parameter]
...

The Makefile's static target compiles without -Wall -Wextra, so the project's own builds do not print it. The same command prints 12 other warnings with gcc (sign comparisons, variables it reports as maybe used uninitialized, and an unused p_vector parameter in sqlite-vec-diskann.c), and the p_vector one with clang; this PR leaves those as they are.

sqlite3_vec_init() now marks pApi with UNUSED_PARAMETER() in the SQLITE_CORE case. The change comes from photostructure#9 (d89dbcf), and is open on vlasky/sqlite-vec as vlasky#23, where sqlite3_vec_numpy_init() and sqlite3_vec_static_blobs_init() have the same warning. No other open or closed PR or issue here marks it.

Test. The command above prints the pApi warning on main and not on this branch, with either compiler. UNUSED_PARAMETER() is a (void) cast, so the object files are byte-identical before and after, both for the loadable extension and with -DSQLITE_CORE. The Python tests (tests/test-*.py: 239 passed, 66 skipped) pass. make test-unit does not compile on main; with #305 and #319 merged it compiles and passes on Linux arm64, with this change and without it. (#305 alone fails there, in test_vec0_parse_partition_key_definition's empty-definition case: the && guards #319 corrects read the scanner's token after it found none, so the result depends on what the stack held.) It merges cleanly with #327 to #331 and #336 to #340.

Compiled with -DSQLITE_CORE, as when sqlite-vec.c is built into SQLite or
an application, sqlite3_vec_init() never reads its pApi parameter, since
SQLITE_EXTENSION_INIT2() is its only use and SQLITE_CORE leaves it out. With
-Wall -Wextra it warns:

    gcc -Ivendor -Wall -Wextra -DSQLITE_CORE -DSQLITE_VEC_STATIC \
        -c sqlite-vec.c -o vec.o

    sqlite-vec.c:10633:65: warning: unused parameter 'pApi'

It now marks it with UNUSED_PARAMETER() in that case. The command no longer
prints that warning with gcc 14.2 or clang 19.1, and the loadable
extension, built without SQLITE_CORE, is unchanged.

This branch has not been deployed

No deployments
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