QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3079|回复: 2

per_cpu奇怪的宏定义!

[复制链接]
发表于 2006-9-15 13:34:56 | 显示全部楼层 |阅读模式
请教大虾们,下面两条宏定义做如何理解.
1.#define per_cpu(var, cpu)                        (*((void)(cpu), &per_cpu__##var))
2.#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))

有两个问题:
1.第一条宏的返回值是什么(相比之下,第二条倒好理解,就是RELOC_HIDE的返回值)?
2.两条宏定义中的##是连接符吗?
还请大虾不吝赐教,谢谢!
发表于 2006-9-16 01:03:33 | 显示全部楼层
1. 逗号隔开的多个表达式(e1,e2,...,en),括起后组成的表达式的值是en。
2. 是。
回复

使用道具 举报

 楼主| 发表于 2006-9-16 09:44:03 | 显示全部楼层

谢谢

我看了一下info GCC C Extensions 部分,发现下面的解释有些类似:

Compound expressions, conditional expressions and casts are allowed
as lvalues provided their operands are lvalues.  This means that you
can take their addresses or store values into them.

   For example, a compound expression can be assigned, provided the last
expression in the sequence is an lvalue.  These two expressions are
equivalent:

   
(a, b) += 5
     a, (b += 5)


   Similarly, the address of the compound expression can be taken.
These two expressions are equivalent:

   
&(a, b)
     a, &b


那么我是否可以从上面的表达式类推得到

   *(e1,en)
equivalent to:
      e1,*en
回复

使用道具 举报

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

本版积分规则

GMT+8, 2024-4-25 12:06 , Processed in 0.065665 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

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