lua-users home
lua-l archive

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


On Wed, May 23, 2012 at 12:33 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Wed, May 23, 2012 at 2:18 AM, Rena <hyperhacker@gmail.com> wrote:
>> How does lua_load() react if Lua was compiled without the ability to
>> compile code? Is there a reliable way to embed Lua code in a C
>> library?
>
> If you did retain the ability to compile code, then there is another
> option which is as portable as you wish it to be.
>
> And that's to embed the source directly in a C file, as a properly
> escaped multiline C string, which is then loaded.
>
> const char *code = \
> "function boo(x)\n" \
> " print(\"hello\",x)\n" \
> "end\n"
>
> I did this with winapi, for about a hundred lines of simple utility
> functions that would be tedious to code in C.  I don't know when one
> hits preprocessor limitations, however.
>
> If working with LuaJIT, then there's an option to compile Lua files as
> object files containing the bytecode, which can be directly linked
> with the project.
>
> steve d.
>

That's what I do now, but I wanted to remove the runtime dependency on
luac. A compile-time dependency shouldn't be a big deal, though it
might still be problematic if you're compiling for a different
platform...

-- 
Sent from my Game Boy.