Luc*_*cas 1 c++ lua symbols c++11
我的C++项目中有一个Lua实现的奇怪问题.出于某种原因,它不允许执行包含诸如#
(:
,%
以及更重要,更重要)等运算符的脚本.
在结果中......
我需要用for i = 1, table.getn(tbl) do
而不是for i = 1, #tbl do
.
我需要用string.gsub(str, [..])
而不是str:gsub([..])
.
等等...这真的很烦人寻找解决方法.
我的第一个想法是编码.我尝试过多种常见编码,但没有一种工作.
我遇到的错误:
使用时str:gsub([..])
代替string.gsub(str, [..])
:
attempt to index global `str' (a string value)
Run Code Online (Sandbox Code Playgroud)
使用时#tbl
代替table.getn(tbl)
:
unexpected symbol near `#'
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?我会感谢每一个解决方案,因为我没有想法.
规格:
Lua版本:
#define LUA_VERSION "Lua 5.0.3"
Run Code Online (Sandbox Code Playgroud)
C++ 11,FreeBSD 10
长度运算符是lua 5.1的补充.它在lua 5.0中不存在.
类似地,默认字符串metatable似乎是lua 5.1添加.
比较lua 5.0实现luaopen_string
的lua 5.1实现luaopen_string
.
类似地(再次)模运算也是5.1加法.比较Arithmetic Operators
的部分5.0 manual
和`5.1手动1.
5.1手册部分包括操作员定义的内容,以便您自己实现(或使用您需要的任何其他定义).