We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is no documented va_list alternative for use when using C bindings, but looks like there is a partial support when using v translate.
va_list
v translate
File test.c:
#include <stdarg.h> int sum(int qtd, ...) { va_list va; int s = 0; va_start(va, qtd); for (int i=0; i < qtd; i++) { s += (va_arg(va, int)); } va_end(va); return s; } int main() { printf("Result %d\n", sum(3,4,5,6)); return 0; }
Then run: v translate test.c
v translate test.c
Work seamlessly converting to V and, after running the resulting binary print on screen: Result 15
Result 15
The command v translate test.c gives the following error:
C to V translator 0.4.0 translating /tmp/test.c ... test.v:10:9: error: invalid expression: unexpected token `)` 8 | __builtin_va_start(va, qtd) 9 | for i := 0 ; i < qtd ; i ++ { 10 | s += () | ^ 11 | } 12 | __builtin_va_end(va) Internal vfmt error while formatting file: /tmp/test.v. Encountered a total of: 1 errors. took 35 ms ; output .v file: test.v Translated 1 files in 35 ms.
Partial / insufficient implementation of va_list or stdarg.h.
stdarg.h
Even with the error, V still generates a test.v file with the following content:
test.v
@[translated] module main @[c2v_variadic] fn sum(qtd int) int { va := Va_list{} mas := 0 __builtin_va_start(va, qtd) for i := 0 ; i < qtd ; i ++ { s += () } __builtin_va_end(va) return s } fn main() { C.printf(c'Result %d\n', sum(3, 4, 5, 6)) return }
0.4.4 0205154
v doctor output:
V full version: V 0.4.4 65a1d2f.0205154 OS: linux, Debian GNU/Linux bookworm/sid Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz getwd: /tmp vexe: /opt/v/v vexe mtime: 2024-01-23 01:53:07 vroot: OK, value: /opt/v VMODULES: OK, value: /home/thadeu/.vmodules VTMP: OK, value: /tmp/v_101000 Git version: git version 2.34.1 Git vroot status: weekly.2024.03-53-g02051540 .git/config present: true CC version: cc (Debian 12.2.0-14) 12.2.0 thirdparty/tcc status: thirdparty-linux-amd64 12f392c3-dirty
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
There is no documented
va_list
alternative for use when using C bindings, but looks like there is a partial support when usingv translate
.Reproduction Steps
File test.c:
Then run:
v translate test.c
Expected Behavior
Work seamlessly converting to V and, after running the resulting binary print on screen:
Result 15
Current Behavior
The command
v translate test.c
gives the following error:Possible Solution
Partial / insufficient implementation of
va_list
orstdarg.h
.Additional Information/Context
Even with the error, V still generates a
test.v
file with the following content:V version
0.4.4 0205154
Environment details (OS name and version, etc.)
v doctor output:
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: