From f45d3f07ede2b3403e54341f5e6496a46e118126 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 4 Oct 2019 05:40:08 +0300 Subject: [PATCH] fix 3 last C warnings and make sure no new warnings are introduced --- compiler/comptime.v | 2 +- compiler/main.v | 13 +++++++++++++ vlib/builtin/int.v | 2 +- vlib/time/time.v | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/compiler/comptime.v b/compiler/comptime.v index 99c8e1802d..14be5a1d1b 100644 --- a/compiler/comptime.v +++ b/compiler/comptime.v @@ -277,7 +277,7 @@ fn (p mut Parser) gen_struct_str(typ Type) { sb.writeln('fn (a $typ.name) str() string {\nreturn') sb.writeln("'{") for field in typ.fields { - sb.writeln('\t$field.name: \$a.${field.name}') + sb.writeln('\t$field.name: $' + 'a.${field.name}') } sb.writeln("\n}'") sb.writeln('}') diff --git a/compiler/main.v b/compiler/main.v index 56e92e176a..c194653fcd 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -1078,6 +1078,19 @@ fn (v &V) test_v() { println('vlib/ is missing, it must be next to the V executable') exit(1) } + if !os.dir_exists(parent_dir + '/compiler') { + println('compiler/ is missing, it must be next to the V executable') + exit(1) + } + // Make sure v.c can be compiled without warnings + $if mac { + os.system('$vexe -o v.c compiler') + if os.system('cc -Werror v.c') != 0 { + println('cc failed to build v.c without warnings') + exit(1) + } + println('v.c can be compiled without warnings. This is good :)') + } // Emily: pass args from the invocation to the test // e.g. `v -g -os msvc test v` -> `$vexe -g -os msvc $file` mut joined_args := args.right(1).join(' ') diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index 545c06db30..919ffbe5d8 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -252,7 +252,7 @@ pub fn (n i64) hex() string { 19 } hex := malloc(len) - count := int(C.sprintf(*char(hex), '0x%lx', n)) + count := int(C.sprintf(*char(hex), '0x%llx', n)) return tos(hex, count) } diff --git a/vlib/time/time.v b/vlib/time/time.v index 9228cfc538..06fcb93f1c 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -38,7 +38,7 @@ struct C.tm { tm_sec int } -fn C.time(int) i64 +fn C.time(int) C.time_t pub fn now() Time { t := C.time(0)