Commit 317afa6
builtin: fix GetFinalPathNameByHandleW declaration for TCC on Windows
TCC''s bundled <windows.h> does not include <fileapi.h>, so
GetFinalPathNameByHandleW had no C declaration in scope when TCC
compiled any program that pulled in builtin (e.g. via os.real_path).
TCC (in C99 mode) treats implicit function declarations as hard errors.
Provide the declaration for TCC only, via a header that is #insert-ed
under $if windows and guarded with `#ifdef __TINYC__`:
- TCC: __TINYC__ is defined, so the extern is supplied. TCC''s own
<fileapi.h> cannot be used instead because it pulls in <apiset.h>,
a header TCC does not ship.
- GCC/MSVC: __TINYC__ is not defined, so the extern is skipped and the
call resolves against the SDK header that <windows.h> pulls in
transitively. Emitting a V-side extern here would conflict with the
SDK''s `DWORD WINAPI` signature (DWORD is unsigned long, not u32).
Gating in the C preprocessor (rather than a comptime `$if tinyc`) is
deliberate: it keeps the guard intact under `-cross`, where V emits all
declarations unconditionally. The same `#ifdef __TINYC__` idiom is
already used for TCC/Windows in vlib/v/gen/c/cheaders.v.
Verified on Windows: generated C wraps the extern in `#ifdef __TINYC__`
for both normal and -cross GCC builds (gcc compiles both with no
conflict), and `vlib/os/` tests pass (24/24) with GCC.
Co-Authored-By: WOZCODE <contact@withwoz.com>1 parent 6c4d26f commit 317afa6
2 files changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments