not logged in | [Login]
The canonical way to convert a cdata pointer to a Lua number is:
tonumber(ffi.cast('intptr_t', ffi.cast('void *', ptr)))
This returns a signed result, which is cheaper to handle and turns into a no-op, when JIT-compiled. If you really need an unsigned address (and not just an abstract identifier), then use uintptr_t. Source