lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, 2011-02-26 at 18:26 +0100, Andrew Yourtchenko wrote:
> The "include" part assumes the headers are in their places, and uses
> the popen of "echo '#include <filename.h>' | gcc -E -" with some
> filtering to get the data.
> 
> This is all fine and dandy. The problem with this method is that it
> produces duplicate definitions (since each include is treated
> separately). This makes luajit unhappy.

Well, exactly because of this problem, I preprocess all the include
files at once - so that the preprocessor itself can remove all the
duplicates. Maybe you could try something like this:

ffi.include { "stdio.h", "time.h", "unistd.h", ... } -- you get the idea

Or, another way to do this is just to collect all the arguments into a
table, and then use a function like processAllHeaders() that will do the
same thing as I did manually.

The last option (IMO not good) would be to patch LuaJIT to ignore
redefinitions altogether...