本文介绍了宏:#define a(b)({... c;})意味着a(b)返回c吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux内核中有以下代码:

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;
})

我以前从未见过这样定义的宏,这是否意味着task_cred_xxx(task,xxx)返回___ val?

I never saw macro defined like this before, does that mean this is task_cred_xxx(task, xxx) returns ___val?

谢谢!

推荐答案

正确.它将返回___val.但是,像这样的块表达式是GNU扩展,实际上并不是C标准的一部分.

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/

这篇关于宏:#define a(b)({... c;})意味着a(b)返回c吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 17:01
查看更多