V: main fails compile if it returns a value

Created on 5 Jul 2019  Â·  7Comments  Â·  Source: vlang/v

V version: V 0.1.12
OS:

What did you do?

fn main() int
{
        return 0
}

What did you expect to see?
nothing ;-)

What did you see instead?

/home/alf//.vlang//ex-main.c:3095:13: error: expected ‘;’ before numeric constant
  return   0 0 ;
             ^
V panic: clang error
Bug

Most helpful comment

In V you use exit(code) for this

All 7 comments

main shouldn't return a value :-) . Why do you want it to?

Well the language should not allow this. It's a quick fix.

main should return value to inspect return code in scripts, for example

In V you use exit(code) for this

ok, agreed then

Fixed:

fn main must have no arguments and no return values

ok, agreed. nice for embedded systems
So exit() is/becomes a builtin function?
args will come via a os module?

Is the plan to get rid of accessing C lib via C.function interface? Or will this stay part of V?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vtereshkov picture vtereshkov  Â·  3Comments

cjmxp picture cjmxp  Â·  3Comments

ArcDrake picture ArcDrake  Â·  3Comments

choleraehyq picture choleraehyq  Â·  3Comments

radare picture radare  Â·  3Comments