I have this code in linux kernel:
#define task_cred_xxx(task, xxx)
({
__typeof_开发者_开发百科_(((struct cred *)NULL)->xxx) ___val;
rcu_read_lock();
___val = __task_cred((task))->xxx;
rcu_read_unlock();
___val;
})
I never saw macro defined like this before, does that mean this is task_cred_xxx(task, xxx) returns ___val?
Thanks!
Correct. It will return ___val
. However, block expressions like these are a GNU extension and isn't actually part of the C standard.
http://www.toofishes.net/blog/gcc-compound-statement-expressions/
精彩评论