I need to ccall
a function that expects a C FILE *
. To have the function write to a file on disk, I figured out that I can get an appropriate FILE *
using
foo = open("foo.txt", "w")
Libc.FILE(foo)
This works fine, but I’d also like to be able to have this work for stdout
. So I tried:
Libc.FILE(stdout)
ERROR: MethodError: no method matching fd(::Base.TTY)
Closest candidates are:
fd(::Base.Filesystem.File) at filesystem.jl:231
fd(::IOStream) at iostream.jl:36
Stacktrace:
[1] Base.Libc.FILE(::Base.TTY) at ./libc.jl:87
[2] top-level scope at none:0
I can instead do
Libc.FILE(RawFD(1), "w")
but is the fact that Libc.FILE(stdout)
doesn’t work an oversight?