builtin: declare fn C._vinit/2 and fn C._vcleanup/0 (continuation from #23812) (#23820)

This commit is contained in:
Delyan Angelov 2025-02-28 05:23:48 +02:00 committed by GitHub
parent 8aef3c72b4
commit c17c0e16c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View File

@ -6,6 +6,12 @@ pub type FnExitCb = fn ()
fn C.atexit(f FnExitCb) int
fn C.strerror(int) &char
// These functions (_vinit, and _vcleanup), are generated by V, and if you have a `module no_main` program,
// you should ensure to call them when appropriate.
fn C._vinit(argc int, argv &&char)
fn C._vcleanup()
@[markused]
fn v_segmentation_fault_handler(signal_number i32) {
$if freestanding {

View File

@ -7,6 +7,8 @@ module builtin
// g_original_codepage - used to restore the original windows console code page when exiting
__global g_original_codepage = u32(0)
// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
// See https://www.codeproject.com/KB/string/cppstringguide1.aspx
pub type C.BOOL = int
pub type C.HINSTANCE = voidptr
@ -25,6 +27,20 @@ pub type C.HANDLE = voidptr
pub type C.LRESULT = voidptr
pub type C.CHAR = char
pub type C.TCHAR = u16 // It is u8 if UNICODE is not defined, but for V programs it always is
pub type C.WCHAR = u16
pub type C.LPSTR = &char
pub type C.LPWSTR = &C.WCHAR
pub type C.LPTSTR = &C.TCHAR
pub type C.LPCTSTR = &C.TCHAR
// utf8 to stdout needs C.SetConsoleOutputCP(cp_utf8)
fn C.GetConsoleOutputCP() u32

View File

@ -1,6 +1,5 @@
module test
fn C._vinit(int, voidptr)
fn C.GC_INIT()
const foo = 1