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

  • From: Ryan Gonzalez <rymg19@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 26 Nov 2013 21:20:18 -0600

I NEW something would be wrong! Like I said, it was untested, hence the
fact I made a stupid mistake.


On Tue, Nov 26, 2013 at 9:11 PM, Coda Highland <chighland@xxxxxxxxx> wrote:

> 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
>
>


-- 
Ryan
When your hammer is C++, everything begins to look like a thumb.

Other related posts: