Debugging generated C code
To debug issues in the generated C code, you can pass these flags:
-cg
- produces a less optimized executable with more debug information in it.-showcc
- prints the C command that is used to build the program.
For the best debugging experience, you can pass all of them at the same time: v -cg -showcc yourprogram.v
, then just run your debugger (gdb/lldb) or IDE on the produced executable yourprogram
.
If you just want to inspect the generated C code, without further compilation, you can also use the -o
flag (e.g. -o file.c
). This will make V produce the file.c
then stop.
If you want to see the generated C source code for just a single C function, for example main
, you can use: -printfn main -o file.c
.
To see a detailed list of all flags that V supports, use v help
, v help build
and v help build-c
.