I've been fussing around for days trying to figure out what the cause of this error is: "invalid C type at line 12" I made a test case, the bug wasn't there. I messed with the test case even more, still couldn't reproduce it. Eventually, I found out what was causing it. It turns out that if you define a type in more than one place ANYWHERE in your application, it will cause Luajit to generate that error when it is used inside of a function prototype (it is not produced for global variables). If this is in any way intended behaviour, it should have a significantly better error message... As for working around it, how would I use a type in two different Lua files without defining it twice (or running a file twice, for that matter)?