jmckaskill / luaffi

Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.
469 stars 84 forks source link

Global constants don't work #7

Closed fjolnir closed 12 years ago

fjolnir commented 12 years ago

As far as I can tell, cdef only lets you define functions or types. Meaning that code like the following does not work(Does work fine in LuaJIT however)

ffi.cdef[[
// http://clang.llvm.org/docs/Block-ABI-Apple.txt
struct __block_descriptor_1 {
    unsigned long int reserved; // NULL
    unsigned long int size; // sizeof(struct __block_literal_1)
};

struct __block_literal_1 {
    struct __block_literal_1 *isa;
    int flags;
    int reserved;
    void *invoke;
    struct __block_descriptor_1 *descriptor;
};

const struct __block_literal_1 *_NSConcreteGlobalBlock; // <-- problem line
]]

Fails with: unexpected type in root on line 15

jmckaskill commented 12 years ago

Thanks for the report. I've added it to the todo list and will hopefully look at it some time this week.