Re: ffi type of pointer to

  • From: Mike Pall <mike-1206@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 12 Jun 2012 16:27:40 +0200

Justin Cormack wrote:
> Would it be possible to add an ffi function that takes a ctype and returns
> the ctype of a pointer to that type? (ffi.ptrtype(ct) or something?

Well, it's not that difficult to do for the pointer case. But I'd
rather go for parameterized types, e.g.

  ffi.typeof("$ *", foo_t)
  ffi.typeof("struct { $ k; $ v; }[?]", foo_t, bar_t)

But I'm not sure whether the complexity is really worth it.

> I seem to have a lot of code that needs to cast bits of memory returned
> from ffi C functions to different types

Why is that? Can you give an example?


Other related posts: