评估赋值语句的返回值

dan*_*aul 2 c

我的理解是,在C中评估赋值语句时,也会返回赋值.
但是,当我运行下面的代码时,似乎并非如此.当source_next_level(GLib队列)为空时,g_queue_pop_head()函数返回NULL,然后将其分配给current_q_node.
然而,while循环条件检查中的!= NULL比较似乎不会评估此比较,因为即使current_q_node为NULL也会输入while循环.

当g_queue_pop_head返回NULL时,为什么输入while循环?

while((current_q_node = g_queue_pop_head(source_next_level)) != NULL);
{
  if(current_q_node == NULL) puts("It doesn't seem this should ever be printed but it is");
}
Run Code Online (Sandbox Code Playgroud)

oua*_*uah 5

while((current_q_node = g_queue_pop_head(source_next_level)) != NULL);
                                                                    ^^^
Run Code Online (Sandbox Code Playgroud)

你还有一个额外的;.