Re: newbie question: ffi.sizeof()

  • From: Duncan Cross <duncan.cross@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 20 Jun 2012 11:19:16 +0100

On Wed, Jun 20, 2012 at 11:07 AM, Patrick Masotta <masottaus@xxxxxxxxx> wrote:
>
> Hi Duncan,
> I did what you say but I'm getting sz=0, not 50 as expected ... :-(
> The C string is there with the correct initial value and all of that..
> I just cannot get its size.
> what could be wrong?
>
> thanks
>

I can't reproduce your problem I'm afraid. If I do:

do
  local ffi = require 'ffi'
  local var_01 = ffi.new("char[50]", "initial value for var_01")
  sz = ffi.sizeof(var_01)
  print(sz)
end

...it does print 50.

-Duncan

Other related posts: