| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5510 人关注过本帖
标题:关于用宏来定义函数。。
只看楼主 加入收藏
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
啊。。大家帮助一下哈。

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-07-15 16:14
VxWorks
Rank: 3Rank: 3
来 自:WindRiver
等 级:论坛游民
威 望:6
帖 子:859
专家分:68
注 册:2007-11-24
收藏
得分:0 
既然要使用返回值,也可以将接受返回值的变量作参数传递进去,像add2一样。
只想到这两种方法,感觉都没什么意义,可以用inline函数代替。


这里已经说了,add2(a,b,sum)就是一个例子,sum = add(a,b)改写成add2(a,b,sum)问题就解决了,用入口参数带出返回值。
不过我还是坚持最初的看法 I strongly recommend inline function !

为了防止世界被破坏,为了守护世界的和平,贯彻爱与真实的邪恶,可爱又迷人的反派角色,VxWorks!
Don't ask me any question.I'm just here to buy soy sauce.
2008-07-15 18:51
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
好办法。。

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-07-15 20:02
蓝色神话
Rank: 2
等 级:论坛游民
威 望:1
帖 子:404
专家分:24
注 册:2006-5-11
收藏
得分:0 
为什么非要用宏,这样对代码的易读性有破坏!
2008-07-15 20:47
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
我用bcc55里面还不支持inline
只有用__inline这样兼容性

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-07-16 10:46
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
不好

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-07-16 10:47
VxWorks
Rank: 3Rank: 3
来 自:WindRiver
等 级:论坛游民
威 望:6
帖 子:859
专家分:68
注 册:2007-11-24
收藏
得分:0 
#define  __inline   inline

能在编译参数中定义这个宏更好

为了防止世界被破坏,为了守护世界的和平,贯彻爱与真实的邪恶,可爱又迷人的反派角色,VxWorks!
Don't ask me any question.I'm just here to buy soy sauce.
2008-07-16 17:34
快速回复:关于用宏来定义函数。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018425 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved