per_cpu奇怪的宏定义!
请教大虾们,下面两条宏定义做如何理解.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))
有两个问题:
1.第一条宏的返回值是什么(相比之下,第二条倒好理解,就是RELOC_HIDE的返回值)?
2.两条宏定义中的##是连接符吗?
还请大虾不吝赐教,谢谢! 1. 逗号隔开的多个表达式(e1,e2,...,en),括起后组成的表达式的值是en。
2. 是。
谢谢
我看了一下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
页:
[1]