luatcc 方便你写lua扩展

52 views
Skip to first unread message

sagasw

unread,
Aug 9, 2009, 8:54:20 PM8/9/09
to lu...@googlegroups.com


关键字: luatcc
当要用c实现lua的模块的时候  就涉及到模块的编译 调试 运行 而这些步骤很繁琐,容易出错,有了luatcc就可以直接在lua代码里面直接写c代码了 动态运行 岂不是很cool, 大大提高了开发速度。
luatcc项目网站: http://luaforge.net/projects/lua-tcc/

require "lua_tcc"

m = tcc.compile ([[

        #include "lua.h"

        typedef struct {
                void *s;
        } tcc_userdata;

        void hi (void) {
                printf ("hello world!\n");
        }

        void bye (void) {
                printf ("bye yufeng.!\n");
        }

        int count (lua_State *L) {
                printf ("hay %d parametros\n", lua_gettop (L));
                lua_pushnumber (L, lua_gettop (L));
                return 1;
        }

]], {"hi", "bye", "count", }, {"m"})

m.hi()
m.count("", 1,2,3,4)
Reply all
Reply to author
Forward
0 new messages