From 8d1eb759f7e255f408b66965698d82465c16ce75 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 16 Nov 2019 21:49:55 +0300 Subject: [PATCH] fix v -o foo.c build module foo --- vlib/builtin/bare/string_bare.v | 4 +--- vlib/compiler/cc.v | 1 + vlib/compiler/main.v | 4 +++- vlib/compiler/parser.v | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/vlib/builtin/bare/string_bare.v b/vlib/builtin/bare/string_bare.v index df67c69c18..32a03aa33d 100644 --- a/vlib/builtin/bare/string_bare.v +++ b/vlib/builtin/bare/string_bare.v @@ -8,9 +8,7 @@ pub: pub fn strlen(s byteptr) int { mut i := 0 - for i = 0; s[i] != 0; i++ { - - } + for ; s[i] != 0; i++ {} return i } diff --git a/vlib/compiler/cc.v b/vlib/compiler/cc.v index a71566ab59..d9e2b0871d 100644 --- a/vlib/compiler/cc.v +++ b/vlib/compiler/cc.v @@ -31,6 +31,7 @@ fn (v mut V) cc() { vdir := os.dir(vexe) // Just create a C/JavaScript file and exit // for example: `v -o v.c compiler` + println('CC() $v.out_name') if v.out_name.ends_with('.c') || v.out_name.ends_with('.js') { // Translating V code to JS by launching vjs. // Using a separate process for V.js is for performance mostly, diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index 97f316352c..b99ca38979 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -838,7 +838,9 @@ pub fn new_v(args[]string) &V { mod = mod_path.replace(os.path_separator, '.') println('Building module "${mod}" (dir="$dir")...') //out_name = '$TmpPath/vlib/${base}.o' - out_name = mod + if !out_name.ends_with('.c') { + out_name = mod + } // Cross compiling? Use separate dirs for each os /* if target_os != os.user_os() { diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 546256e7cf..7022664434 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -1501,7 +1501,7 @@ fn (p mut Parser) get_var_type(name string, is_ptr bool, deref_nr int) string { // *var if deref_nr > 0 { /* - if !p.inside_unsafe { + if !p.inside_unsafe && !p.pref.building_v && p.mod != 'os' { p.error('dereferencing can only be done inside an `unsafe` block') } */