diff --git a/vlib/os/os.v b/vlib/os/os.v index f46fc8a589..0408c82dbb 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -301,7 +301,11 @@ pub fn fileno(cfile voidptr) int { $if windows { return C._fileno(cfile) } $else { - return C.fileno(cfile) + cfile_casted := &C.FILE(0) // FILE* cfile_casted = 0; + cfile_casted = cfile + // Required on FreeBSD/OpenBSD/NetBSD as stdio.h defines fileno(..) with a macro + // that performs a field access on its argument without casting from void*. + return C.fileno(cfile_casted) } }