[英]C variable declaration missing
I came across the following code, I don't understand how this variable "win" works here without declaration? 我遇到了以下代码,我不了解此变量“ win”在没有声明的情况下如何工作?
//The following code is in a header file
static inline void Win_unlink(list_t * list, Win * shm_win)
{
SHM_Win_t *elem = NULL;
SHM_Win_t *tmp_elem = NULL;
SEARCH_SCALAR(*list, elem, win, shm_win);
if (elem != NULL) {
tmp_elem = elem;
MPL_DL_DELETE(*list, elem);
MPL_free(tmp_elem);
}
}
#define SEARCH_SCALAR(head,out,field,val) SEARCH_SCALAR_N(head,out,field,val,next)
#define SEARCH_SCALAR_N(head,out,field,val,_next) \
do { \
FOREACH_N(head,out,_next) { \
if ((out)->field == (val)) break; \
} \
} while(0)
I looked at the included header files, but there is no variable declared as "win". 我查看了包含的头文件,但是没有声明为“ win”的变量。 I also looked at the places where this function is called, I didn't find the declaration for "win" either.
我还查看了调用此函数的地方,也没有找到“ win”的声明。 I used cscope to look for global definition of win, but I didn't see it.
我使用cscope查找win的全局定义,但没有看到。
Looking at the definition of SEARCH_SCALAR
and SEARCH_SCALAR_N
, it seems to me that win
is not an independent variable. 查看
SEARCH_SCALAR
和SEARCH_SCALAR_N
的定义,在我看来win
并不是一个独立变量。 It represents a field/member of a struct
. 它代表
struct
的字段/成员。
if ((out)->field == (val)) break;
^^^^ that's win in your use.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.