os: fix build issue caused by fileno on *BSD

pull/5090/head
Matt Baulch 2020-05-28 19:08:59 +10:00 committed by GitHub
parent a3bd8d3e4c
commit c7501e2d3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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)
}
}