diff --git a/Makefile b/Makefile index 1b323dfe1d..df5246b3bc 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ ifdef WIN32 $(CC) -std=gnu11 -DUNICODE -D_UNICODE -w -o v0.exe vc/v_win.c ./v0.exe -o v.exe compiler else - $(CC) -std=gnu11 -w -o v vc/v.c -lm + $(CC) -std=gnu11 -o v vc/v.c -lm endif rm -rf vc/ @echo "V has been successfully built" diff --git a/compiler/parser.v b/compiler/parser.v index 389140a751..57a32412c9 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -2052,7 +2052,6 @@ fn (p mut Parser) expression() string { println('expression() pass=$p.pass tok=') p.print_tok() } - p.cgen('/* expr start*/') ph := p.cgen.add_placeholder() mut typ := p.term() is_str := typ=='string' @@ -2123,10 +2122,14 @@ fn (p mut Parser) expression() string { typ = p.dot(typ, ph) } } - // + - | - for p.tok == .plus || p.tok == .minus || p.tok == .pipe || p.tok == .amp || p.tok == .xor { + // + - | ^ + for p.tok == .plus || p.tok == .minus || p.tok == .pipe || p.tok == .amp || + p.tok == .xor { // for p.tok in [.plus, .minus, .pipe, .amp, .xor] { tok_op := p.tok + if typ == 'bool' { + p.error('operator ${p.tok.str()} not defined on bool ') + } is_num := typ == 'void*' || typ == 'byte*' || is_number_type(typ) p.check_space(p.tok) if is_str && tok_op == .plus && !p.is_js { diff --git a/september.plan b/september.plan index e7bc583e50..efaab00de6 100644 --- a/september.plan +++ b/september.plan @@ -16,7 +16,7 @@ - v ui for linux - doom.v + tcc backend -- fix all c warnings with -pedantic ++ fix all c warnings with -pedantic + set up pvs - ui/orm demo: a simple gui client for postgres/mysql/sqlite - ui demo: calculator diff --git a/vlib/os/os.v b/vlib/os/os.v index c16a8c46b8..547495115a 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -457,12 +457,12 @@ pub fn filename(path string) string { // get_line returns a one-line string from stdin pub fn get_line() string { str := get_raw_line() - $if windows { - return str.trim_right('\r\n') - } - $else { - return str.trim_right('\n') - } + $if windows { + return str.trim_right('\r\n') + } + $else { + return str.trim_right('\n') + } } // get_raw_line returns a one-line string from stdin along with '\n' if there is any @@ -476,16 +476,13 @@ pub fn get_raw_line() string { return '' } $else { - //u64 is used because C.getline needs a size_t as second argument - //Otherwise, it would cause a valgrind warning and may be dangerous - //Malloc takes an int as argument so a cast has to be made - max := u64(256) - buf := malloc(int(max)) + max := size_t(256) + buf := *char(malloc(int(max))) nr_chars := C.getline(&buf, &max, stdin) if nr_chars == 0 { return '' } - return string(buf, nr_chars) + return string(byteptr(buf), nr_chars) } } @@ -591,6 +588,9 @@ fn on_segfault(f voidptr) { } } +fn C.getpid() int +fn C.proc_pidpath (int, byteptr, int) int + pub fn executable() string { $if linux { mut result := malloc(MAX_PATH) @@ -738,6 +738,10 @@ pub fn signal(signum int, handler voidptr) { C.signal(signum, handler) } + +fn C.fork() int +fn C.wait() int + pub fn fork() int { $if !windows { pid := C.fork() diff --git a/vlib/os/os_nix.v b/vlib/os/os_nix.v index f06c9b7733..67d4ddda87 100644 --- a/vlib/os/os_nix.v +++ b/vlib/os/os_nix.v @@ -39,7 +39,7 @@ pub fn ls(path string) []string { if isnil(ent) { break } - name := tos_clone(ent.d_name) + name := tos_clone(byteptr(ent.d_name)) if name != '.' && name != '..' && name != '' { res << name } diff --git a/vlib/time/time.v b/vlib/time/time.v index c216da13a1..9228cfc538 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -38,6 +38,8 @@ struct C.tm { tm_sec int } +fn C.time(int) i64 + pub fn now() Time { t := C.time(0) mut now := &C.tm{!}