相关疑难解决方法(0)

编译器警告 - 建议用作真值的赋值括号

当我尝试编译下面的代码时,我收到此警告:

warning: suggest parentheses around assignment used as truth value

为什么会这样?我相信这是一个相当普遍的习语.我甚至在我的代码中使用了类似的东西.

struct PIDList* 
getRecordForPID(struct PIDList* list, pid_t pid) {
    while(list = list->next)
        if (list->pid == pid)
            return list;

    return NULL;
}
Run Code Online (Sandbox Code Playgroud)

c compiler-construction compiler-warnings

43
推荐指数
3
解决办法
10万
查看次数