|
1鱼币
#define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
1. lua_register ("strfind", str_find);
lua_pushcfunction,lua_storeglobal 都是函数 像上面那样调用 会调用这两个函数吗?
应该理解成
(lua_pushcfunction(str_find), lua_storeglobal(strfind));
还是
lua_pushcfunction(str_find);
lua_storeglobal(strfind);
ps 这是我从lua代码里翻到的 最进都在研究它的代码 有没有懂得教教我如何看它的代码? 我想把它移植到单片机里 好像有人做到了
|
最佳答案
查看完整内容
(lua_pushcfunction(str_find), lua_storeglobal(strfind));
这个语句包含了一个逗号运算符,会对运算的前面后后面的表达式求值,也就是对
lua_pushcfunction(str_find)和
lua_pushcfunction(str_find)求值
求值的过程中长生副作用,就是调用了这两个函数。值求完由于没有保存,就丢弃了。
所以以上代码等价于
lua_pushcfunction(str_find);
lua_storeglobal(strfind);
|