diff --git a/vlib/clipboard/clipboard_windows.c.v b/vlib/clipboard/clipboard_windows.c.v index 44489250f8..bac7db9b17 100644 --- a/vlib/clipboard/clipboard_windows.c.v +++ b/vlib/clipboard/clipboard_windows.c.v @@ -22,9 +22,9 @@ struct WndClassEx { fn C.RegisterClassEx(class &WndClassEx) int -fn C.GetClipboardOwner() &C.HWND +fn C.GetClipboardOwner() C.HWND -fn C.CreateWindowEx(dwExStyle i64, lpClassName &u16, lpWindowName &u16, dwStyle i64, x int, y int, nWidth int, nHeight int, hWndParent i64, hMenu voidptr, h_instance voidptr, lpParam voidptr) &C.HWND +fn C.CreateWindowEx(dwExStyle i64, lpClassName &u16, lpWindowName &u16, dwStyle i64, x int, y int, nWidth int, nHeight int, hWndParent i64, hMenu voidptr, h_instance voidptr, lpParam voidptr) C.HWND // fn C.MultiByteToWideChar(CodePage u32, dw_flags u16, lpMultiByteStr byteptr, cbMultiByte int, lpWideCharStr u16, cchWideChar int) int fn C.EmptyClipboard() @@ -59,7 +59,7 @@ pub struct Clipboard { max_retries int retry_delay int mut: - hwnd C.HWND + hwnd voidptr foo int // TODO remove } @@ -96,15 +96,16 @@ fn new_clipboard() &Clipboard { lpsz_menu_name: 0 h_icon_sm: 0 } - if C.RegisterClassEx(&wndclass) == 0 && C.GetLastError() != u32(C.ERROR_CLASS_ALREADY_EXISTS) { + if C.RegisterClassEx(voidptr(&wndclass)) == 0 + && C.GetLastError() != u32(C.ERROR_CLASS_ALREADY_EXISTS) { println('Failed registering class.') } hwnd := C.CreateWindowEx(0, wndclass.lpsz_class_name, wndclass.lpsz_class_name, 0, 0, 0, 0, 0, C.HWND_MESSAGE, C.NULL, C.NULL, C.NULL) - if hwnd == C.NULL { + if hwnd == unsafe { nil } { println('Error creating window!') } - cb.hwnd = hwnd + cb.hwnd = voidptr(hwnd) return cb } @@ -116,7 +117,7 @@ pub fn (cb &Clipboard) check_availability() bool { // has_ownership returns true if the contents of // the clipboard were created by this clipboard instance. pub fn (cb &Clipboard) has_ownership() bool { - return C.GetClipboardOwner() == cb.hwnd + return voidptr(C.GetClipboardOwner()) == cb.hwnd } // clear empties the clipboard contents. @@ -140,13 +141,13 @@ const cp_utf8 = 65001 // the string.to_wide doesn't work with SetClipboardData, don't know why fn to_wide(text string) C.HGLOBAL { - len_required := C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, text.str, + len_required := C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, voidptr(text.str), text.len + 1, C.NULL, 0) buf := C.GlobalAlloc(C.GMEM_MOVEABLE, i64(sizeof(u16)) * len_required) if buf != unsafe { nil } { mut locked := &u16(C.GlobalLock(buf)) - C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1, - locked, len_required) + C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, voidptr(text.str), + text.len + 1, locked, len_required) unsafe { locked[len_required - 1] = u16(0) } diff --git a/vlib/dl/dl_windows.c.v b/vlib/dl/dl_windows.c.v index 41e2460ead..f4f946b080 100644 --- a/vlib/dl/dl_windows.c.v +++ b/vlib/dl/dl_windows.c.v @@ -28,7 +28,7 @@ pub fn close(handle voidptr) bool { // sym returns an address of an exported function or variable from a given module. pub fn sym(handle voidptr, symbol string) voidptr { - return C.GetProcAddress(handle, symbol.str) + return C.GetProcAddress(handle, voidptr(symbol.str)) } // dlerror provides a text error diagnostic message for functions in `dl` diff --git a/vlib/os/os.c.v b/vlib/os/os.c.v index 00271d6815..00c33f6ec8 100644 --- a/vlib/os/os.c.v +++ b/vlib/os/os.c.v @@ -554,7 +554,7 @@ pub fn get_raw_line() string { h_input := C.GetStdHandle(C.STD_INPUT_HANDLE) mut bytes_read := u32(0) if is_atty(0) > 0 { - x := C.ReadConsole(h_input, buf, max_line_chars * 2, &bytes_read, 0) + x := C.ReadConsole(h_input, buf, max_line_chars * 2, voidptr(&bytes_read), 0) if !x { return tos(buf, 0) } @@ -563,7 +563,7 @@ pub fn get_raw_line() string { mut offset := 0 for { pos := buf + offset - res := C.ReadFile(h_input, pos, 1, &u32(&bytes_read), 0) + res := C.ReadFile(h_input, pos, 1, voidptr(&bytes_read), 0) if !res && offset == 0 { return tos(buf, 0) } @@ -605,7 +605,7 @@ pub fn get_raw_stdin() []u8 { mut offset := 0 for { pos := buf + offset - res := C.ReadFile(h_input, pos, block_bytes, &u32(&bytes_read), 0) + res := C.ReadFile(h_input, pos, block_bytes, voidptr(&bytes_read), 0) offset += bytes_read if !res { break diff --git a/vlib/os/os_windows.c.v b/vlib/os/os_windows.c.v index 83b1964d0c..641092619e 100644 --- a/vlib/os/os_windows.c.v +++ b/vlib/os/os_windows.c.v @@ -486,7 +486,7 @@ pub fn uname() Uname { pub fn hostname() !string { hostname := [255]u16{} size := u32(255) - res := C.GetComputerNameW(&hostname[0], &size) + res := C.GetComputerNameW(&hostname[0], voidptr(&size)) if !res { return error(get_error_msg(int(C.GetLastError()))) } @@ -496,7 +496,7 @@ pub fn hostname() !string { pub fn loginname() !string { loginname := [255]u16{} size := u32(255) - res := C.GetUserNameW(&loginname[0], &size) + res := C.GetUserNameW(&loginname[0], voidptr(&size)) if !res { return error(get_error_msg(int(C.GetLastError()))) } diff --git a/vlib/os/password_windows.c.v b/vlib/os/password_windows.c.v index 273c444bc6..1175fd2968 100644 --- a/vlib/os/password_windows.c.v +++ b/vlib/os/password_windows.c.v @@ -12,7 +12,7 @@ pub fn input_password(prompt string) !string { std_handle := C.GetStdHandle(C.STD_INPUT_HANDLE) mut mode := u32(0) - unsafe { C.GetConsoleMode(std_handle, &mode) } + unsafe { C.GetConsoleMode(std_handle, voidptr(&mode)) } unsafe { C.SetConsoleMode(std_handle, mode & (~u32(C.ENABLE_ECHO_INPUT))) } defer { diff --git a/vlib/os/process_windows.c.v b/vlib/os/process_windows.c.v index 6d9b67f596..d9b4a724dc 100644 --- a/vlib/os/process_windows.c.v +++ b/vlib/os/process_windows.c.v @@ -8,14 +8,14 @@ fn C.GetProcAddress(handle voidptr, procname &u8) voidptr fn C.TerminateProcess(process HANDLE, exit_code u32) bool fn C.PeekNamedPipe(hNamedPipe voidptr, lpBuffer voidptr, nBufferSize int, lpBytesRead voidptr, lpTotalBytesAvail voidptr, lpBytesLeftThisMessage voidptr) bool -type FN_NTSuspendResume = fn (voidptr) +type FN_NTSuspendResume = fn (voidptr) u64 -fn ntdll_fn(name &u8) FN_NTSuspendResume { +fn ntdll_fn(name &char) FN_NTSuspendResume { ntdll := C.GetModuleHandleA(c'NTDLL') if ntdll == 0 { return FN_NTSuspendResume(0) } - the_fn := FN_NTSuspendResume(C.GetProcAddress(ntdll, name)) + the_fn := FN_NTSuspendResume(C.GetProcAddress(ntdll, voidptr(name))) return the_fn } @@ -123,7 +123,7 @@ fn (mut p Process) win_spawn_process() int { to_be_freed << work_folder_ptr } - create_process_ok := C.CreateProcessW(0, &wdata.command_line[0], 0, 0, C.TRUE, creation_flags, + create_process_ok := C.CreateProcessW(0, voidptr(&wdata.command_line[0]), 0, 0, C.TRUE, creation_flags, 0, work_folder_ptr, voidptr(&start_info), voidptr(&wdata.proc_info)) failed_cfn_report_error(create_process_ok, 'CreateProcess') if p.use_stdio_ctl { @@ -212,7 +212,7 @@ fn (mut p Process) win_read_string(idx int, maxbytes int) (string, int) { return '', 0 } mut bytes_avail := int(0) - if !C.PeekNamedPipe(rhandle, unsafe { nil }, int(0), unsafe { nil }, &bytes_avail, + if !C.PeekNamedPipe(rhandle, unsafe { nil }, int(0), unsafe { nil }, voidptr(&bytes_avail), unsafe { nil }) { return '', 0 } diff --git a/vlib/time/time_windows.c.v b/vlib/time/time_windows.c.v index 7f7c69ea9c..466043f01e 100644 --- a/vlib/time/time_windows.c.v +++ b/vlib/time/time_windows.c.v @@ -64,20 +64,20 @@ fn make_unix_time(t C.tm) i64 { fn init_win_time_freq() u64 { f := u64(0) - C.QueryPerformanceFrequency(&f) + C.QueryPerformanceFrequency(voidptr(&f)) return f } fn init_win_time_start() u64 { s := u64(0) - C.QueryPerformanceCounter(&s) + C.QueryPerformanceCounter(voidptr(&s)) return s } // sys_mono_now returns a *monotonically increasing time*, NOT a time adjusted for daylight savings, location etc. pub fn sys_mono_now() u64 { tm := u64(0) - C.QueryPerformanceCounter(&tm) // XP or later never fail + C.QueryPerformanceCounter(voidptr(&tm)) // XP or later never fail return (tm - time.start_time) * 1000000000 / time.freq_time } @@ -86,7 +86,7 @@ pub fn sys_mono_now() u64 { [inline] fn vpc_now() u64 { tm := u64(0) - C.QueryPerformanceCounter(&tm) + C.QueryPerformanceCounter(voidptr(&tm)) return tm } @@ -112,7 +112,7 @@ pub fn (t Time) local() Time { millisecond: u16(t.nanosecond / 1_000_000) } st_local := SystemTime{} - C.SystemTimeToTzSpecificLocalTime(unsafe { nil }, &st_utc, &st_local) + C.SystemTimeToTzSpecificLocalTime(unsafe { nil }, voidptr(&st_utc), voidptr(&st_local)) t_local := Time{ year: st_local.year month: st_local.month @@ -133,9 +133,9 @@ fn win_now() Time { ft_utc := C._FILETIME{} C.GetSystemTimeAsFileTime(&ft_utc) st_utc := SystemTime{} - C.FileTimeToSystemTime(&ft_utc, &st_utc) + C.FileTimeToSystemTime(&ft_utc, voidptr(&st_utc)) st_local := SystemTime{} - C.SystemTimeToTzSpecificLocalTime(unsafe { nil }, &st_utc, &st_local) + C.SystemTimeToTzSpecificLocalTime(unsafe { nil }, voidptr(&st_utc), voidptr(&st_local)) t := Time{ year: st_local.year month: st_local.month @@ -157,7 +157,7 @@ fn win_utc() Time { ft_utc := C._FILETIME{} C.GetSystemTimeAsFileTime(&ft_utc) st_utc := SystemTime{} - C.FileTimeToSystemTime(&ft_utc, &st_utc) + C.FileTimeToSystemTime(&ft_utc, voidptr(&st_utc)) t := Time{ year: st_utc.year month: st_utc.month