Re: how to send lua table to c/c++ by luajit.ffi ?

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 26 Nov 2013 19:11:01 -0800

On Tue, Nov 26, 2013 at 7:06 PM, Ryan Gonzalez <rymg19@xxxxxxxxx> wrote:
> I think you need this:
>
> ffi.cdef[[
> typedef struct { char* a, b, c; } mystruct;
> ]]
>
> mystruct = ffi.new("mystruct[?]", 3)
> mystruct[0] = "a";
> mystruct[1] = "b";
> mystruct[2] = "c";
>
> Note that I quickly hacked this together, and it is UNTESTED!!!

That should be "char *a, *b, *c;" or else you've defined a structure
containing one string and two single characters.

/s/ Adam

Other related posts: