From c7501e2d3ddcfc32ec875a18c222fb9420028d8f Mon Sep 17 00:00:00 2001 From: Matt Baulch Date: Thu, 28 May 2020 19:08:59 +1000 Subject: [PATCH] os: fix build issue caused by fileno on *BSD --- vlib/os/os.v | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) } }