From f32377e2367312b621f8c6e4ad8df58876ee5ac7 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2026 12:45:32 +0300 Subject: [PATCH] cgen: incompatible redefinition of 'size_t' (fixes #21477) --- vlib/v/gen/c/cheaders.v | 1 - vlib/v/gen/c/custom_start_freestanding_test.v | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index 4c1046ae0..1a5f0812a 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -628,7 +628,6 @@ typedef void (*MapFreeFn)(voidptr); const c_bare_headers = c_helper_macros + c_common_macros + ' #define _VFREESTANDING -typedef long unsigned int size_t; // Memory allocation related headers void *malloc(size_t size); void *calloc(size_t nitems, size_t size); diff --git a/vlib/v/gen/c/custom_start_freestanding_test.v b/vlib/v/gen/c/custom_start_freestanding_test.v index 26e4c1851..7e5a75f04 100644 --- a/vlib/v/gen/c/custom_start_freestanding_test.v +++ b/vlib/v/gen/c/custom_start_freestanding_test.v @@ -35,3 +35,10 @@ fn test_linux_bare_startup_stub_stays_for_default_main() { assert generated.contains('.globl _start') assert !generated.contains('// export alias: _start -> main__start') } + +fn test_bare_prelude_uses_stddef_size_t() { + generated := generate_bare_output('module main\n\nfn main() {}\n') + assert generated.contains('#include ') + assert generated.contains('typedef size_t usize;') + assert !generated.contains('typedef long unsigned int size_t;') +} -- 2.39.5