Skip to content

Add memmem shim for Windows to Kotlin LSP resolver#416

Open
noctrex wants to merge 1 commit into
DeusData:mainfrom
noctrex:fix/memmem-missing-on-windows
Open

Add memmem shim for Windows to Kotlin LSP resolver#416
noctrex wants to merge 1 commit into
DeusData:mainfrom
noctrex:fix/memmem-missing-on-windows

Conversation

@noctrex
Copy link
Copy Markdown
Contributor

@noctrex noctrex commented Jun 4, 2026

memmem() is a GNU libc extension and is not provided by any Windows C runtime -- not by msvcrt.dll (MINGW64) nor by ucrtbase.dll (UCRT64), and not declared by MinGW-w64 under any feature-test macro. GCC 16.1.0 promoted implicit function declarations from warning to hard error, so the 27 memmem() calls introduced with the Kotlin hybrid LSP resolver break the Windows build at the operator-detection block in kotlin_eval_expr_type() (internal/cbm/lsp/kotlin_lsp.c).

Add a static inline memmem() at TU scope, guarded by #if defined(_WIN32) so it is active only on Windows (where it is needed) and a no-op everywhere else -- including macOS and the BSDs, whose <string.h> already declares memmem() as a BSD-origin function. The shim covers all 27 call sites in the file -- 26 in kotlin_eval_expr_type (binary and unary operator detection on bounded source-text slices) and one in kt_apply_smart_cast (type-narrowing check for is).

Verified: build/c/prod_lsp_all.o now compiles cleanly on UCRT64 MSYS2.

memmem() is a GNU libc extension and is not provided by any Windows C
runtime -- not by msvcrt.dll (MINGW64) nor by ucrtbase.dll (UCRT64),
and not declared by MinGW-w64 under any feature-test macro. GCC 16.1.0
promoted implicit function declarations from warning to hard error, so
the 27 memmem() calls introduced with the Kotlin hybrid LSP resolver
break the Windows build at the operator-detection block in
`kotlin_eval_expr_type()` (internal/cbm/lsp/kotlin_lsp.c).

Add a static inline memmem() at TU scope, guarded by `#if defined(_WIN32)`
so it is active only on Windows (where it is needed) and a no-op
everywhere else -- including macOS and the BSDs, whose <string.h>
already declares memmem() as a BSD-origin function. The shim covers all
27 call sites in the file -- 26 in kotlin_eval_expr_type (binary and
unary operator detection on bounded source-text slices) and one in
kt_apply_smart_cast (type-narrowing check for `is`).

Verified: build/c/prod_lsp_all.o now compiles cleanly on UCRT64 MSYS2.
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