例如:
Bool NullFunc(const struct timespec *when, const char *who)
{
return TRUE;
}
Run Code Online (Sandbox Code Playgroud)
在C++中,我能够对/*...*/参数进行评论.但当然不是在C中,它给了我错误error: parameter name omitted.
我想知道是否有可能迭代传递给C99中的可变参数宏或使用任何GCC扩展的参数?
例如,是否可以编写一个通用的宏,它接受一个结构,并将其字段作为参数传递,并打印结构中每个字段的偏移量?
像这样的东西:
struct a {
int a;
int b;
int c;
};
/* PRN_STRUCT_OFFSETS will print offset of each of the fields
within structure passed as the first argument.
*/
int main(int argc, char *argv[])
{
PRN_STRUCT_OFFSETS(struct a, a, b, c);
return 0;
}