美文网首页
Lua 标准库(standard libraries)

Lua 标准库(standard libraries)

作者: 玻璃缸里的自游 | 来源:发表于2018-12-06 08:33 被阅读0次

    一、Lua十标准大库:

    basic library、coroutine library、package library、string manipulation、basic UTF-8 support、table manipulation、mathematical functions、input and output、operating system facilities、debug facilities.

    To have acces to these libraries, the C host program should call the luaL_openlibs functions, which opens all standard libraries. Alternatively, the host program can open them individually by using luaL_requiref to call luaopen_base、luaopen_coroutine、luaopen_package、luaopen_string、luaopen_utf8、luaopen_table、luaopen_math、luaopen_io、luaopen_os、luaopen_debug. These functions are declared in lualib.h.

    例子:

    1)创建lua虚拟机

    lua_State *lua_state = luaL_newstate();

    2)加载Lua库

    a、luaL_openlibs(lua_state);

    b、luaL_requiref(lua_state, "base", luaopen_base, 1);

        lua_pop(lua_state,1);

    相关文章

      网友评论

          本文标题:Lua 标准库(standard libraries)

          本文链接:https://www.haomeiwen.com/subject/vclycqtx.html