lua-users home
lua-l archive

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


"pan shizhu" <pan.shizhu@gmail.com> wrote:

> Hi all,
> 
> The question is probably more C-related rather than Lua-related.
> 
> I want to use Lua inside C program and sometimes it would be
> convenient if I can write lua source inside a C string.
> 
> As far as I know the ISO standard for C requires the quotation mark
> "" to be within one single line. (Though actually most C compilers
> allow multi-line string inside ""). May I ask if there's an
> ISO-compliant way to embed multi-line string in C program?
> 
> Regards,
> Pan, Shi Zhu

I believe you can do the following:

char *luaCode = "function foo()\n"
    "  print('foo')\n"
    "end";

Not ideal, but hey, it works.

-Rob Hoelz