V version: V 0.1.22 1ccd197
OS: Ubuntu 19.04
What did you do?
I'm trying to compile the code in the image of #2761
What did you expect to see?
A beautiful binary working on bare metal
What did you see instead?
The following message
/tmp/v/scratch.tmp.c: In function ‘main__write’:
/tmp/v/scratch.tmp.c:101:26: warning: passing argument 1 of ‘main__syscall5’ makes pointer from integer without a cast [-Wint-conversion]
return main...
(Use `v -g` to print the entire error message)
V error: C error. This should never happen.
Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose
This is the entire error message:
```C compiler=cc
all .v files:
["/secretpath/v/vlib/builtin/bare/builtin_bare.v", "/secretpath/v/vlib/builtin/bare/string_bare.v", "scratch.v"]
/secretpath/v/vlib/builtin/bare/string_bare.v: In function ‘tos’:
/secretpath/v/vlib/builtin/bare/string_bare.v:17:15: error: incompatible type for argument 1 of ‘panic_debug’
panic('tos(): nil string')
^~
/secretpath/v/vlib/builtin/bare/builtin_bare.v:11:26: note: expected ‘string’ {aka ‘struct string’} but argument is of type ‘int’
//write(1, s.str, s.len)
~^
/secretpath/v/vlib/builtin/bare/string_bare.v:17:2: error: too many arguments to function ‘panic_debug’
panic('tos(): nil string')
^~~
/secretpath/v/vlib/builtin/bare/builtin_bare.v:11:7: note: declared here
//write(1, s.str, s.len)
^~~
/secretpath/v/vlib/builtin/bare/string_bare.v: In function ‘tos2’:
/secretpath/v/vlib/builtin/bare/string_bare.v:38:15: error: incompatible type for argument 1 of ‘panic_debug’
panic('tos2: nil string')
^~
/secretpath/v/vlib/builtin/bare/builtin_bare.v:11:26: note: expected ‘string’ {aka ‘struct string’} but argument is of type ‘int’
//write(1, s.str, s.len)
~~~^
/secretpath/v/vlib/builtin/bare/string_bare.v:38:2: error: too many arguments to function ‘panic_debug’
panic('tos2: nil string')
^~~
/secretpath/v/vlib/builtin/bare/builtin_bare.v:11:7: note: declared here
//write(1, s.str, s.len)
^~~
/secretpath/v/vlib/builtin/bare/string_bare.v: In function ‘tos3’:
/secretpath/v/vlib/builtin/bare/string_bare.v:48:15: error: incompatible type for argument 1 of ‘panic_debug’
panic('tos3: nil string')
^~
/secretpath/v/vlib/builtin/bare/builtin_bare.v:11:26: note: expected ‘string’ {aka ‘struct string’} but argument is of type ‘int’
//write(1, s.str, s.len)
~~~^
/secretpath/v/vlib/builtin/bare/string_bare.v:48:2: error: too many arguments to function ‘panic_debug’
panic('tos3: nil string')
^~~
/secretpath/v/vlib/builtin/bare/builtin_bare.v:11:7: note: declared here
//write(1, s.str, s.len)
^~~~~
/secretpath/v/scratch.v: In function ‘main__write’:
/secretpath/v/scratch.v:5:26: warning: passing argument 1 of ‘main__syscall5’ makes pointer from integer without a cast [-Wint-conversion]
return syscall5(1, fd, data, nbytes, 0, 0)
^
/secretpath/v/scratch.v:3:8: note: expected ‘void *’ but argument is of type ‘int’
^
/secretpath/v/scratch.v:5:30: warning: passing argument 2 of ‘main__syscall5’ makes pointer from integer without a cast [-Wint-conversion]
return syscall5(1, fd, data, nbytes, 0, 0)
^~
/secretpath/v/scratch.v:3:8: note: expected ‘void *’ but argument is of type ‘int’
^
/secretpath/v/scratch.v:5:42: warning: passing argument 4 of ‘main__syscall5’ makes pointer from integer without a cast [-Wint-conversion]
return syscall5(1, fd, data, nbytes, 0, 0)
^~
/secretpath/v/scratch.v:3:8: note: expected ‘void *’ but argument is of type ‘u64’ {aka ‘long unsigned int’}
^
/secretpath/v/scratch.v:5:9: warning: returning ‘void *’ from a function with return type ‘int’ makes integer from pointer without a cast [-Wint-conversion]
return syscall5(1, fd, data, nbytes, 0, 0)
^~~~~~~~~
/secretpath/v/scratch.v: In function ‘main__main’:
/secretpath/v/scratch.v:9:20: error: incompatible type for argument 2 of ‘main__write’
write(1, "Hello from V running on bare metal!n", 37)
^~~~~~~~~
/secretpath/v/scratch.v:4:32: note: expected ‘void *’ but argument is of type ‘string’ {aka ‘struct string’}
fn write(fd int, data voidptr, nbytes u64) int {
~~^~~~
V error: C error. This should never happen.
Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose```
I fixed it changing adding the right types to the arguments
fn syscall5(number int, arg1 int, arg2 string, arg3 u64, arg4 u64, arg5 voidptr) int
fn write(fd int, data string, nbytes u64) int {
return syscall5(1, fd, data, nbytes, 0, 0)
}
fn main() {
write(1, "Hello from V running on bare metal!\n", 37)
}
Most helpful comment
I fixed it changing adding the right types to the arguments