Re[4]: ffi.istype() on arrays

  • From: Roman Tsisyk <roman@xxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 02 Jul 2015 12:52:05 +0300




Thursday, July 2, 2015 11:35 AM +02:00 from Wolfgang Pupp
<wolfgang.pupp@xxxxxxxxx>:

char[] -> char * is valid cast in C.

Yes. It is also a valid cast in LuaJIT.
Invalid casts (like float to pointer) raise an error.

Arrays are even compatible with pointers, meaning that the cast is not
needed; a LuaJIT-FFI-function expecting a pointer will also accept an
array instead.

What are you trying to achieve?

I want to check function arguments.
On Lua string - one branch, on 'char *' - another branch, otherwise error.


--
WBR,
Roman Tsisyk <roman@xxxxxxxxxxxxx>
http://tarantool.org/ - an efficient in-memory data store and a Lua
application server

Other related posts: