c - 警告 : control reaches end of non-void function; error: null undeclared (c)

标签 c

q_node * pop(Queue * que) {
   if ((que->size == 0) || (que == NULL)) return null;
   q_node * item = que->head;
   if (freeNode(que)) {
      que->size--;
      return item;
   } else return null;
}

当我尝试编译时,我收到此函数底线的上述警告。结构体 q_node 和 Queue 编译没有任何问题,freeNode() 也是如此......你知道我做错了什么吗?

我还收到第一个 if 语句行的错误“null undeclared”。

最佳答案

q_node * pop(Queue * que) {
   if ((que->size == 0) || (que == NULL)) return NULL;
   q_node * item = que->head;
   if (freeNode(que)) {
      que->size--;
      return item;
   }
   return NULL;
}

去掉else语句是没有用的。现在没有警告了^_^ Gcc 发现您错过了最后的 return 语句,并让您知道以防万一。

编辑:空->空

关于c - 警告 : control reaches end of non-void function; error: null undeclared (c),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12994890/

相关文章:

c - 在 C 中实现 strrchr 时复制字符串的问题

arrays - 这段代码是做什么的。检查两个字符串的字谜

计算二叉搜索树中的平均数

c - 如何强制宏不展开

c++ - 你如何在 c 中交换结构数组的元素?

c - 即使在下一次迭代之后,是否在循环中局部声明了一个变量,该循环创建了一个可以在被调用线程中安全使用的线程?

c 中 char * 缓冲区的 Python 样式 repr?

c - 为什么对(超过)三个无符号字符的算术运算在使用 -Wconversion 时总是触发警告?

c - 这段C代码是否可以编译?

c - OCamlcstub 性能