主函数的返回值范围 [英] Return value range of the main function

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

问题描述

标准对主要返回值范围有何看法? 最多只能说255个?

What does standard say about main return values range? Say only up to 255?

因为

int main(void){
return 256;
}
echo $? ;  # out 0

推荐答案

标准未说明. 0EXIT_SUCCESSEXIT_FAILURE具有(某种)指定的含义.其他一切取决于实现.

The standard doesn't say. 0, EXIT_SUCCESS and EXIT_FAILURE have (sort of) specified meanings. Anything else depends on the implementation.

目前,大多数基于Unix的系统仅支持8位返回值. Windows支持(至少)32位返回值.我尚未检查64位Windows是否支持64位返回值,但我对此表示怀疑,因为即使64位Windows通常仍使用32位int.

At the present time, most Unix-based systems only support 8-bit return values. Windows supports (at least) a 32-bit return value. I haven't checked whether 64-bit Windows supports a 64-bit return value, but I rather doubt it, since even 64-bit Windows normally still uses a 32-bit int.

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

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