[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C helloworld from inside Ravi
- From: Dibyendu Majumdar <mobile@...>
- Date: Tue, 20 Jun 2017 01:23:13 +0100
On 20 June 2017 at 01:13, Sean Conner <sean@conman.org> wrote:
> Nice. Are you planning on supporting?
>
> local testfunc = [[
> #include <stdio.h>
> #include <lua.h>
>
> int TestFunc(lua_State *L)
> {
> puts("hello world!\n");
> return 0;
> }
> ]]
>
Yes a pre-processor is present. However to successfully parse header
files many platform specific extensions have to be understood by the C
parser, and the underlying implementation being derived from Linux
Sparse project doesn't understand MSVC extensions.
> That's something my own C compiler module [1] does:
>
> local cc = require "org.conman.cc"
>
> local CODE = [[
> #include <stdio.h>
> #include <lua.h>
>
> int TestFunc(lua_State *L)
> {
> puts("hello world!\n");
> return 0;
> }
> ]]
>
> local f = cc.compile("TestFunc",CODE)
> f()
>
> -spc
>
> [1] https://github.com/spc476/lua-conmanorg/blob/master/lua/cc.lua [2]
>
> [2] It's based on TCC, not LLVM. It also adds another loader to load
> lua modules written in C directly from C source code.
>
Cool. But TCC is GPL licensed.
Regards