q66 / cffi-lua

A portable C FFI for Lua 5.1+
MIT License
176 stars 24 forks source link

Problem with simple "typedef" #40

Closed stustd closed 1 year ago

stustd commented 1 year ago

When copying from a LuaJit.FFI interface, in order to get the CFFI version working I had to remove simple typedefs like

typedef long type_t;

and use the long instead. This is the CFFI error msg I get with typedef declarations:

input:1: ';' expected near 'time_t'

Any hope this can be integrated with CFFI? (... or am I doing something wrong; couldn't find an example or test using it.)

q66 commented 1 year ago

i realized that tests for this were missing, so i added some in the referenced commit, but it seems to be working fine? Your error message indicates you're creating a typedef with the name time_t, which is an existing builtin type and a keyword, so you cannot redefine it

q66 commented 1 year ago

It seems luajit allows you to redefine "builtin" typedefs (even though it doesn't do anything). I changed the behavior to allow the same, but I'd advise you not to redefine them