`
mryufeng
  • 浏览: 968885 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

luatcc 方便你写lua扩展

    博客分类:
  • Lua
阅读更多
当要用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)
3
0
分享到:
评论
1 楼 mryufeng 2008-07-19  
root@yfnix:~/tcc/lua-5.1.3/src# tcc -lm lapi.c lcode.c ldo.c  lgc.c   llex.c loadlib.c loslib.c lstring.c  ltablib.c  lundump.c  print.c lauxlib.c ldblib.c  ldump.c  linit.c lmathlib.c  lobject.c lparser.c  lstrlib.c  ltm.c lvm.c lbaselib.c  ldebug.c  lfunc.c  liolib.c  lmem.c lopcodes.c  lstate.c ltable.c  lzio.c -run lua.c
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> print "hello"
hello
>

很cool哦

相关推荐

Global site tag (gtag.js) - Google Analytics