From 58941fe0c1fb802b9dd353ce0a46e077ae2a11ae Mon Sep 17 00:00:00 2001 From: kbkpbot Date: Mon, 24 Nov 2025 23:00:50 +0800 Subject: [PATCH] builtin: fix C.SYSTEM_INFO (fix #25788) (#25823) --- vlib/builtin/cfns.c.v | 14 +++++++------- vlib/v/tests/windows_system_info_test.v | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 vlib/v/tests/windows_system_info_test.v diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index 7821f68eb..653da878e 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -552,18 +552,18 @@ fn C.sysconf(name int) int // C.SYSTEM_INFO contains information about the current computer system. This includes the architecture and type of the processor, the number of processors in the system, the page size, and other such information. @[typedef] pub struct C.SYSTEM_INFO { - // DUMMYUNIONNAME union { - // dwOemId u32 - // DUMMYSTRUCTNAME struct { - // pub: - // wProcessorArchitecture u16 - // wReserved u16 + // workaround: v doesn't support a truely C anon union/struct here + // union { + dwOemId u32 + // struct { + wProcessorArchitecture u16 + wReserved u16 // } //} dwPageSize u32 lpMinimumApplicationAddress voidptr lpMaximumApplicationAddress voidptr - dwActiveProcessorMask &u32 = unsafe { nil } + dwActiveProcessorMask u32 dwNumberOfProcessors u32 dwProcessorType u32 dwAllocationGranularity u32 diff --git a/vlib/v/tests/windows_system_info_test.v b/vlib/v/tests/windows_system_info_test.v new file mode 100644 index 000000000..b16933302 --- /dev/null +++ b/vlib/v/tests/windows_system_info_test.v @@ -0,0 +1,8 @@ +// vtest build: windows + +fn test_windows_system_info() { + x := C.SYSTEM_INFO{} + C.GetSystemInfo(&x) + assert x.wProcessorArchitecture != 0 + assert x.dwPageSize == 4096 +} -- 2.39.5