lua-users home
lua-l archive

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


Johnson Lin wrote:
> I was thinking there're reasons behind this design (about loading C
> libraries into different namespaces), but we have only one ffi.cdef,
> thus comes my original question that if we can have different cdef's
> namespaces too. After your explanation, I am thinking then why not:
> 
> ffi.load(path_to_LibA); ffi.cdef[[ LibA_declarations... ]]
> 
> ffi.C.LibA_Init()
> --or
> local C = ffi.C
> C.LibA_Init()

Sure, you can load a library into the global namespace:
  http://luajit.org/ext_ffi_api.html#ffi_load

But that won't work on Windows, because it doesn't have a global
symbol namespace. So yes, there are reasons behind the design of
the FFI library ...

--Mike