lua-users home
lua-l archive

Re: Is it possible to send var-args (...) to a native function?

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


Try the code below and then compare to your own.
-- in Lua:
print(construct(10,20,30,40))
-- in C:
static int construct(lua_State* L)
{
	int stack_size = lua_gettop(L);
	printf("construct %d items in stack\n",stack_size);
	lua_pushinteger(L,stack_size);
	return 1;
}
...
	lua_register(L, "construct", construct);

AltStyle によって変換されたページ (->オリジナル) /