C函数的隐式int返回值 [英] Implicit int return value of C function

查看:141
本文介绍了C函数的隐式int返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我GOOGLE了,只是似乎无法找到答案,这个简单的问题。

I've googled and just can't seem to find the answer to this simple question.

这是一个传统code基工作(移植到Linux最近,慢慢升级到新的编译器),我看到了很多

Working on a legacy code base (ported to Linux recently, and slowly updating to a new compiler) and I see a lot of

int myfunction(...)
{
// no return...
}

我知道一个函数的隐式返回类型为int,但是没有指定的回报时,什么是隐式的返回值。我测试过,并得到0,但这只是用gcc。这是编译器特定的或者是定义为0的标准呢?

I know the implicit return TYPE of a function is int, but what is the implicit return VALUE when no return is specified. I've tested and gotten 0, but that's only with gcc. Is this compiler specific or is it standard defined to 0?

推荐答案

从'89标准引述新约圣经:

From the '89 standard as quoted in the new testament:

流动关闭的函数的末尾相当于无前pression回报。在两种情况下,返回值是未定义的。

Flowing off the end of a function is equivalent to a return with no expression. In either case, the return value is undefined.

这是通常的标准前presses上实地pre-现有实现的行为。

That standard usually expresses the on-the-ground behavior of pre-existing implementations.

这篇关于C函数的隐式int返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆