Add memmem shim for Windows to Kotlin LSP resolver#416
Open
noctrex wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 foris).Verified: build/c/prod_lsp_all.o now compiles cleanly on UCRT64 MSYS2.