Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这个宏有什么作用?我无法理解它的定义:
#define PAIR(def) [def] = { .name = #def, .val = def, },
来自:ltp-full-20120401/lib/tst_res.c 第 183 行
您可以从此链接获取源代码
看起来它是用来初始化结构数组的。
如下使用的宏PAIR(FOOBAR)将扩展为:
PAIR(FOOBAR)
[FOOBAR] = { .name = "FOOBAR", .val = FOOBAR, },
.name并且.val将是struct数组元素类型的成员。
.name
.val
struct