Skip to content

Commit b278d09

Browse files
builtin: fix GetFinalPathNameByHandleW declaration for TCC on Windows
TCC''s bundled windows.h does not chain-include fileapi.h, so GetFinalPathNameByHandleW had no C declaration in scope when TCC compiled any program that pulled in builtin. TCC (in C99 mode) treats implicit function declarations as hard errors. Add an explicit #include <fileapi.h> inside a $if windows {} block alongside the function declaration. V already passes thirdparty/tcc/include/winapi to TCC''s include search path, so TCC resolves the declaration from its own bundled header (which carries the correct DWORD WINAPI signature). GCC and MSVC receive a harmless redundant include since fileapi.h has include guards. Keeping the declaration in $if windows {} also stops it from being compiled into Linux/macOS builds, where the symbol does not exist. Co-Authored-By: WOZCODE <contact@withwoz.com>
1 parent c0624b2 commit b278d09

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

vlib/builtin/cfns.c.v

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ fn C.CreateFile(lpFilename &u16, dwDesiredAccess u32, dwShareMode u32, lpSecurit
295295
fn C.CreateFileW(lpFilename &u16, dwDesiredAccess u32, dwShareMode u32, lpSecurityAttributes &u16, dwCreationDisposition u32,
296296
dwFlagsAndAttributes u32, hTemplateFile voidptr) voidptr
297297

298-
fn C.GetFinalPathNameByHandleW(hFile voidptr, lpFilePath &u16, nSize u32, dwFlags u32) u32
298+
$if windows {
299+
#include <fileapi.h>
300+
301+
fn C.GetFinalPathNameByHandleW(hFile voidptr, lpFilePath &u16, nSize u32, dwFlags u32) u32
302+
}
299303

300304
fn C.CreatePipe(hReadPipe &voidptr, hWritePipe &voidptr, lpPipeAttributes voidptr, nSize u32) bool
301305

0 commit comments

Comments
 (0)