小编gue*_*est的帖子

从C中的非void函数返回任何内容

在以下代码段中被认为是最佳做法:

int foo(struct data *bar, struct info bla) {
    if (!bar) {
        bla->status = 0;
        return;
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

事实上,它工作正常.但是在gcc给我一个警告时我感到很不舒服.


这是实际的代码:

static int pop(struct stack **stack, struct info *info) {
        int ret;
        struct stack *tmp;

        if (!*stack) {
                info->error = 0;
                return;
        }

        ret = (*stack)->data;
        tmp = *stack;
        *stack = (*stack)->next;
        free(tmp);

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

c gcc warnings return

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

c ×1

gcc ×1

return ×1

warnings ×1