How can I call the C routines lseek
or ftell
or fseek
?
I tried this (macos 10.12.6):
import os
#flag -lsystem
#include <unistd.h>
seeker.v:150:11: error: unknown function: C.lseek
148 | // tell returns the current file position
149 | fn (f os.File) tell() int {
150 | return C.lseek(f.fd, 0, C.SEEK_CUR)
151 | }
You have to declare the C functions before you use them !
fn C.lseek(fd, offset, whence int)
This allows V to know the parameters of the function, and type check them.