首页 > 其他 > 详细

vs2005 测试 lua环境

时间:2014-08-12 18:37:14      阅读:412      评论:0      收藏:0      [点我收藏+]

(1)添加文件核路径


(2)库文件路径

(3)main.cpp

#include <stdio.h>
#include <string.h>

extern "C"{
    #include <lua.h>
    #include <lauxlib.h>
    #include <lualib.h>
}

#pragma comment(lib, "lua51.lib")
#pragma comment(lib, "lua5.1.lib")

int main(int argc, _TCHAR* argv[])
{
    char buff[256];
    int error;

    lua_State *L = lua_open();
    luaL_openlibs(L);

    //lua_State *L = lua_open();                /* opens Lua */
    //luaopen_base(L);                        /* opens the basic library */
    //luaopen_table(L);                        /* opens the table library */
    //luaopen_io(L);                            /* opens the I/O library */
    //luaopen_string(L);                        /* opens the string lib. */
    //luaopen_math(L);                        /* opens the math lib. */

    while (fgets(buff, sizeof(buff), stdin) != NULL) {
        error = luaL_loadbuffer(L, buff, strlen(buff), "line") || lua_pcall(L, 0, 0, 0);
        if (error) {
            fprintf(stderr, "%s", lua_tostring(L, -1));
            lua_pop(L, 1);                    /* pop error message from the stack */
        }
    }
    lua_close(L);
    return 0;
}

vs2005 测试 lua环境,布布扣,bubuko.com

vs2005 测试 lua环境

原文:http://www.cnblogs.com/lynx/p/3907881.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!