Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Fix Windows/MinGW build: TLS, strndup, sys/wait.h
Martin Vogel26a78142d630
diff --git a/src/foundation/compat.h b/src/foundation/compat.hindex 78502675f..3363cd1c4 100644--- a/src/foundation/compat.h+++ b/src/foundation/compat.h@@ -12,11 +12,9 @@#include <stdio.h>/* ── Thread-local storage ─────────────────────────────────────── */-#ifdef _WIN32-#define CBM_TLS __declspec(thread)-#else+/* _Thread_local is C11 standard — works on GCC, Clang, and MSVC (2019+).+ * __declspec(thread) is MSVC-only and doesn't work on MinGW GCC. */#define CBM_TLS _Thread_local-#endif/* ── Sleep ────────────────────────────────────────────────────── */#ifdef _WIN32diff --git a/src/graph_buffer/graph_buffer.c b/src/graph_buffer/graph_buffer.cindex 6ff20e367..0013096de 100644--- a/src/graph_buffer/graph_buffer.c+++ b/src/graph_buffer/graph_buffer.c@@ -12,6 +12,7 @@#include "store/store.h"#include "sqlite_writer.h"#include "foundation/hash_table.h"+#include "foundation/compat.h"#include "foundation/log.h"#include "foundation/dyn_array.h"@@ -841,7 +842,7 @@ static char *extract_url_path(const char *props) {return NULL;}// NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard header- return strndup(key, (size_t)(end - key));+ return cbm_strndup(key, (size_t)(end - key));}int cbm_gbuf_dump_to_sqlite(cbm_gbuf_t *gb, const char *path) {diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.cindex 97498e2da..e59b21001 100644--- a/src/pipeline/pass_calls.c+++ b/src/pipeline/pass_calls.c@@ -139,7 +139,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,const char *end = strchr(start, '"');if (end && end > start) {// NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard header- char *key = strndup(start, end - start);+ char *key = cbm_strndup(start, end - start);keys[count] = key;vals[count] = target->qualified_name;count++;diff --git a/src/pipeline/pass_enrichment.c b/src/pipeline/pass_enrichment.cindex 1c468f15c..4f91d8d40 100644--- a/src/pipeline/pass_enrichment.c+++ b/src/pipeline/pass_enrichment.c@@ -11,6 +11,7 @@#include "foundation/log.h"#include "foundation/hash_table.h"#include "foundation/platform.h"+#include "foundation/compat.h"#include "yyjson/yyjson.h"#include <ctype.h>@@ -46,7 +47,7 @@ int cbm_split_camel_case(const char *s, char **out, int max_out) {if (s[i] >= 'A' && s[i] <= 'Z' && s[i - 1] >= 'a' && s[i - 1] <= 'z') {if (count < max_out) {// NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard header- out[count] = strndup(s + start, i - start);+ out[count] = cbm_strndup(s + start, i - start);count++;}start = i;@@ -54,7 +55,7 @@ int cbm_split_camel_case(const char *s, char **out, int max_out) {}/* Emit remaining */if (count < max_out) {- out[count] = strndup(s + start, len - start);+ out[count] = cbm_strndup(s + start, len - start);count++;}return count;diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.cindex 20b175631..5686828ba 100644--- a/src/pipeline/pass_parallel.c+++ b/src/pipeline/pass_parallel.c@@ -232,7 +232,7 @@ static int build_import_map(const cbm_gbuf_t *gbuf, const char *project_name, coconst char *end = strchr(start, '"');if (end && end > start) {// NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard header- keys[count] = strndup(start, end - start);+ keys[count] = cbm_strndup(start, end - start);vals[count] = target->qualified_name;count++;}diff --git a/src/pipeline/pass_semantic.c b/src/pipeline/pass_semantic.cindex 14c248c7b..e2d81ce3e 100644--- a/src/pipeline/pass_semantic.c+++ b/src/pipeline/pass_semantic.c@@ -131,7 +131,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,const char *end = strchr(start, '"');if (end && end > start) {// NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard header- keys[count] = strndup(start, end - start);+ keys[count] = cbm_strndup(start, end - start);vals[count] = target->qualified_name;count++;}diff --git a/src/pipeline/pass_usages.c b/src/pipeline/pass_usages.cindex 9c3fde703..5746fce7b 100644--- a/src/pipeline/pass_usages.c+++ b/src/pipeline/pass_usages.c@@ -147,7 +147,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,const char *end = strchr(start, '"');if (end && end > start) {// NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard header- keys[count] = strndup(start, end - start);+ keys[count] = cbm_strndup(start, end - start);vals[count] = target->qualified_name;count++;}diff --git a/src/ui/http_server.c b/src/ui/http_server.cindex 7e8f2a6b1..c544b91a2 100644--- a/src/ui/http_server.c+++ b/src/ui/http_server.c@@ -28,8 +28,10 @@#include <stdio.h>#include <stdlib.h>#include <string.h>+#ifndef _WIN32#include <unistd.h>#include <sys/wait.h>+#endif#ifdef __APPLE__#include <mach-o/dyld.h>#endif