lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Some of that looks like C-language, some of that looks like Lua, and I'm not sure what you're asking, but I'll try to help out.  Consider the following Lua code.

local A = { a=1, b=2 }
function Sum( arg )
  return arg.a + arg.b
end
local c = Sum( arg )
print( "c = " .. c )

Assuming I didn't make a mistake, that should print "3".  Notice that variables holding a table value are just pointers to such values.  I don't believe the same is true for variables holding integral or string values, but I don't know much about Lua internals.

On Wed, Mar 6, 2013 at 9:36 PM, Jim zhang <jimzhang02@yahoo.com> wrote:
Code to be test:
struct A
{
   int a,
   int b
};
 
int sum ( struct A * s)
{
   retunr s->a+s->b;
}
 
How could I construct a struct A object in lua scripts, and pass the pointer of this struct into sum() to test it?
 
Thanks,
 
Jim