I'm building a wrapper using LuaJIT and FFI. I have a C library with a function that takes a FILE*
as a parameter. In a Lua function within which I open a file using io.open()
. Is there a way to cast, convert, or extract from the Lua file object to a C FILE*
? This seems like it should be straightforward but I can't find a solution. Thanks in advance.
Asked
Active
Viewed 700 times
4

greatwolf
- 20,287
- 13
- 71
- 105

johnzachary
- 2,435
- 2
- 19
- 9
1 Answers
3
LuaJIT head will automatically convert a Lua file handle to a FILE * (well, void *).
http://www.freelists.org/post/luajit/an-admittedly-lazy-programmer-question,4

jsimmons
- 732
- 1
- 8
- 18