鱼C论坛

 找回密码
 立即注册
查看: 3558|回复: 1

一个关于宏定义的问题

[复制链接]
发表于 2013-7-21 13:47:23 | 显示全部楼层 |阅读模式
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);
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-7-21 13:47:24 | 显示全部楼层
(lua_pushcfunction(str_find), lua_storeglobal(strfind));
这个语句包含了一个逗号运算符,会对运算的前面后后面的表达式求值,也就是对
lua_pushcfunction(str_find)和
lua_pushcfunction(str_find)求值
求值的过程中长生副作用,就是调用了这两个函数。值求完由于没有保存,就丢弃了。

所以以上代码等价于


lua_pushcfunction(str_find);
lua_storeglobal(strfind);
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-18 20:46

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表