//FILE : lua.c
#include
#include
#include
#include
#include
int main(void)
{
char buff[256];
int error;
lua_State* L = luaL_newstate();
luaL_openlibs(L);
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);
}
}
lua_close(L);
return 0;
}
----------------------------------------------------------------------------------
// FILE : Makefile
lua:lua.c
gcc -O2 -o lua lua.c -llua5.1
clean:
rm lua
----------------------------------------------------------------------------------
注意头文件,还有连接时的库 -llua5.1
阅读(1012) | 评论(0) | 转发(0) |