Repository navigation
windows: build under V's bundled tcc - #104
Conversation
V's tcc on Windows could not build ui2: its winapi header set lacks commctrl.h, commdlg.h, shlobj.h and oleacc.h, which the Windows helpers include; it has no uuid import library, which ui_windows.v linked for one interface id; and its hand-listed gdi32.def, kernel32.def and shell32.def lack eight exports the helpers and ui_windows.v call. V then fell back to gcc, which a stock Windows install does not have, so `v run` of any ui2 program needed clang or MSVC. windows/tcc_compat_windows.h, read only under __TINYC__, declares what the helpers use from those four headers (the common-control, tooltip and trackbar messages and structures, the subclassing calls, OPENFILENAMEW and the file dialogs, BROWSEINFOW and the folder browser, the tray icon, and IAccessible's vtable whole, since the helpers call slots past IDispatch's), with the layouts and values of mingw-w64's headers; it fetches the eight missing exports from their DLLs at first use behind macros of their own names (GetGlyphIndicesW, AddFontResourceExW, CreateActCtxW, ActivateActCtx, ReleaseActCtx, SHBrowseForFolderW, SHGetPathFromIDListW, Shell_NotifyIconW); and it undefines `small`, which tcc's rpcndr.h defines as a type unconditionally (mingw-w64's only under RC_INVOKED) and which ui2 has struct fields named after. The three helpers include it in place of the missing headers under __TINYC__, the files that insert them pass the helpers' directory as an include path (V inserts the helper into the generated C, so a quoted include needs it), and IAccessible's id is spelled in native_helpers_windows.h so no compiler links uuid for it. Verified on Windows 11 with V master ee6d62a: examples/editor and examples/gpui_editor build with `-cc tcc -no-retry-compilation`, natively and with -d ui2_custom_rendering, run with their windows up, the native one with themed controls (the activation context works through the wrappers) and the code editor drawn as the clang build draws it; the same examples still build with llvm-mingw's clang. The declared names and the wrapped exports were listed mechanically: every Win32 name the helpers and the V side use, checked against tcc's headers and its .def lists against mingw-w64's import libraries, with known-missing and known-present names as controls. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Three defects stopped the native (non-custom-rendering) tcc build, which
includes native_helpers_windows.h:
- tcc's own shellapi.h (copied from mingw-w64, in V's bundled tcc since
2020) already defines struct _NOTIFYICONDATAW and declares
Shell_NotifyIconW; the compat header redefined the tag, and tcc rejects
a second definition even when identical ('struct/union/enum already
defined' at the shellapi.h include). Include shellapi.h instead and
keep the fallbacks behind #ifndef guards.
- the helpers call IAccessible's accDoDefaultAction
(native_helpers_windows.h:1083), so the slot cannot stay a plain
pointer: tcc says 'function pointer expected'. It is typed now, like
the get_acc* slots the helpers call.
- GetTickCount64 is absent from V's hand-listed kernel32.def, so the
plain declaration left the symbol unresolved at link; it goes through
ui2_tcc_import like the other kernel32 exports.
- WM_MOUSEHWHEEL is missing from tcc's XP-era winuser.h; declared here
like SM_CXPADDEDBORDER.
Verified against the real bundled header set (vlang/tccbin_win): the
whole native_helpers_windows.h, the file-dialog and window-chrome
headers, and every wrapped import compile clean with tcc 0.9.28rc; the
unfixed header reproduces all three failures.
|
Verified on Windows 11 x64 with V 0.5.2 (bundled tcc) and gcc. Builds (native): editor, tray_icon, file_dialog, fontchooser - OK. Notes:
LGTM for the stated goal. |
|
Thank you for the verification on Windows with both compilers. You are right on the count: the header wraps nine exports, not eight; GetTickCount64 is already in V's kernel32.def and its wrapper is redundant. If a follow-up on the five |
yes, pls do. and thank you for your help |
|
Opened as #105: the five handle copies spelled |
What
ui2 builds on Windows with the tcc that V bundles, natively and with
-d ui2_custom_rendering, sov runworks on a stock V install without clang, gcc or MSVC.windows/tcc_compat_windows.h(new, read only under__TINYC__) declares what the Windows helpers use from the four headers tcc's winapi set lacks,commctrl.h,commdlg.h,shlobj.handoleacc.h: the common-control, tooltip and trackbar messages and structures, the subclassing calls,OPENFILENAMEWand the file dialogs,BROWSEINFOWand the folder browser, the tray icon, andIAccessible's vtable whole (the helpers call slots pastIDispatch's). Layouts and values are mingw-w64's.gdi32.def,kernel32.defandshell32.deflack:GetGlyphIndicesW,AddFontResourceExW,CreateActCtxW,ActivateActCtx,ReleaseActCtx,SHBrowseForFolderW,SHGetPathFromIDListW,Shell_NotifyIconW. tcc links those three libraries through the lists, every other one from the DLL's export table.small: tcc'srpcndr.hdefines it as a type unconditionally (mingw-w64's only underRC_INVOKED), and ui2 has struct fields namedsmall, which becamedouble char.__TINYC__;ui_windows.v,file_dialog_windows.c.vandwindow_chrome_windows.c.vadd-I @VMODROOT/windowsso the quoted include resolves (V inserts the helpers into the generated C).-luuidis dropped:IAccessible's id is spelled innative_helpers_windows.h, so no compiler needs uuid for it.Why
On Windows, V's tcc failed on
library 'uuid' not found(native) andcommctrl.h not found(custom rendering), and V's fallback asked for a gcc a stock install does not have:Verified
Windows 11 x86-64, V master ee6d62a.
examples/editorandexamples/gpui_editorbuild withv -cc tcc -no-retry-compilation, natively and with-d ui2_custom_rendering, and run with their windows up; the native build shows themed controls (the activation context goes through the wrappers) and the code editor draws as the clang build draws it. The same examples still build with llvm-mingw's clang. The declared names and the wrapped exports were listed mechanically, every Win32 name the helpers and the V side use against tcc's headers, and tcc's.deflists against mingw-w64's import libraries, with known-missing and known-present names as controls.Not verified
-luuidremoval and the spelled interface id should not affect it, but it was not built.🤖 Generated with Claude Code