Re: an admittedly lazy programmer question...

  • From: Mike Pall <mike-1205@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 28 May 2012 23:34:47 +0200

William Adams wrote:
> Would LuaJIT ffi do anything for me to translate from Luas io to
> this FILE structure?  Can I simply do:
> 
> fh = io.open(file)
> 
> somefunc(fh)
> 
> And have it work?  Assuming I've defined FILE in some FFI place.

Well, I could make it work. But why? If you're working with the
FFI, you'd call ffi.C.fopen() to get a file descriptor, right?

> Alternatively, I could redefine the function signature:
> 
> void somefunc(void *f)

Nope, that doesn't work. The data area of a userdata object is not
the FILE * itself, but it contains a FILE *.

--Mike

Other related posts: