[luatex] Linking to C libraries / TL2017 / FFI

Patrick Gundlach patrick at gundla.ch
Sun Apr 23 18:50:26 CEST 2017


Hello all,

I've tried to use ffi on the Mac (macOS Sierra) and failed with this luajitlatex file:

----------------
\documentclass{article}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
local ffi = require("ffi")


ffi.cdef[[
void Sleep(int ms);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]

local sleep
if ffi.os == "Windows" then
  function sleep(s)
    ffi.C.Sleep(s*1000)
  end
else
  function sleep(s)
    ffi.C.poll(nil, 0, s*1000)
  end
end

for i=1,160 do
  io.write("."); io.flush()
  sleep(0.01)
end
io.write("\n")

\end{luacode*}
\end{document}
----------------

This is the texlive2017 luajittex binary and the sample taken from http://luajit.org/ext_ffi_tutorial.html 

Is this supposed to work with LuaJitLaTeX on a Mac?

Patrick





More information about the luatex mailing list