lua-users home
lua-l archive

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


On Fri, Feb 14, 2014 at 3:23 PM, Coda Highland <chighland@gmail.com> wrote:
On Fri, Feb 14, 2014 at 8:27 AM, Thijs Schreijer
<thijs@thijsschreijer.nl> wrote:
>> -----Original Message-----
>> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
>> Behalf Of Luiz Henrique de Figueiredo
>> Sent: vrijdag 14 februari 2014 16:42
>> To: Lua mailing list
>> Subject: Re: protect a set in c (non-existing elements)
>>
>> If you want to include Lua code in your C code, try "xxd -i".
>
> I like brief answers, but this one was too brief for me :) I have no clue what you mean... can you provide some more details?
>

xxd is a hexdump program, and the -i parameter of it makes it output C
code defining the data as an array.

/s/ Adam


Using a global variable just to pass a parameter to a chunk seems a little clumsy, why not do:

char *chunk =
"local parameter=(...) "
"print(parameter) "
"return {sometable=true}";

LUAMOD_API int luaopen_xtable (lua_State *L) {  luaL_loadstring(L, chunk); 
  luaL_loadstring(L, chunk);
  lua_pushliteral(L,"I am a parameter");
  lua_call(L,1,1);
  return 1;
}