1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix Windows warnings

This commit is contained in:
Nicolas Sauzede
2019-11-16 00:30:50 +01:00
committed by Alexander Medvednikov
parent e577b40743
commit 1dadf9d966
13 changed files with 92 additions and 61 deletions

View File

@ -109,7 +109,7 @@ pub fn read_file(path string) ?string {
pub fn file_size(path string) int {
mut s := C.stat{}
$if windows {
C._wstat(path.to_wide(), &s)
C._wstat(path.to_wide(), voidptr(&s))
} $else {
C.stat(*char(path.str), &s)
}
@ -583,13 +583,13 @@ pub fn get_raw_line() string {
buf := &byte(malloc(max_line_chars*2))
if is_atty(0) > 0 {
h_input := C.GetStdHandle(STD_INPUT_HANDLE)
mut nr_chars := 0
C.ReadConsole(h_input, buf, max_line_chars * 2, &nr_chars, 0)
return string_from_wide2(&u16(buf), nr_chars)
mut nr_chars := u32(0)
C.ReadConsole(h_input, buf, max_line_chars * 2, voidptr(&nr_chars), 0)
return string_from_wide2(&u16(buf), int(nr_chars))
}
res := int( C.fgetws(buf, max_line_chars, C.stdin ) )
res := C.fgetws(&u16(buf), max_line_chars, C.stdin )
len := int( C.wcslen(&u16(buf)) )
if 0 != res { return string_from_wide2( &u16(buf), len ) }
if !isnil(res) { return string_from_wide2( &u16(buf), len ) }
return ''
} $else {
max := size_t(256)
@ -830,7 +830,9 @@ pub fn realpath(fpath string) string {
mut fullpath := calloc( MAX_PATH )
mut res := 0
$if windows {
res = int( C._fullpath( fullpath, fpath.str, MAX_PATH ) )
// here we want an int==0 if _fullpath failed , in which case
// it would return NULL, and !isnil(NULL) would be false==0
res = int( !isnil(C._fullpath( fullpath, fpath.str, MAX_PATH )) )
}
$else{
if fpath.len != strlen(fpath.str) {
@ -900,19 +902,25 @@ fn C.fork() int
fn C.wait() int
pub fn fork() int {
mut pid := -1
$if !windows {
pid := C.fork()
return pid
pid = C.fork()
}
panic('os.fork not supported in windows') // TODO
$if windows {
panic('os.fork not supported in windows') // TODO
}
return pid
}
pub fn wait() int {
mut pid := -1
$if !windows {
pid := C.wait(0)
return pid
pid = C.wait(0)
}
panic('os.wait not supported in windows') // TODO
$if !windows {
panic('os.wait not supported in windows') // TODO
}
return pid
}
pub fn file_last_mod_unix(path string) int {