为什么ARGC一个'诠释'(而不是'无符号整数')? [英] Why is argc an 'int' (rather than an 'unsigned int')?

查看:129
本文介绍了为什么ARGC一个'诠释'(而不是'无符号整数')?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么命令行参数计算变量而不是一个无符号整数'(传统的argc)的'廉政'?是否有技术原因?

Why is the command line arguments count variable (traditionally "argc") an 'int' instead of an 'unsigned int'? Is there a technical reason for this?

我一直不理它时,试图摆脱我所有的签署无符号比较警告,但永远无法理解为什么事情是这样的,它是。

I've always just ignored it when trying rid of all my signed unsigned comparison warnings, but never understood why it is the way that it is.

推荐答案

这是原来的C语言是这样一个事实,即默认的变量或参数被定义为int类型,可能是另一个因素。换句话说,你可以有:

The fact that the original C language was such that by default any variable or argument was defined as type int, is probably another factor. In other words you could have:

  main(argc, char* argv[]);  /* see remark below... */

而不是

int main(int argc, char *argv[]);

修改:有效,亚伦提醒我们,非常原始语法本来像

Edit: effectively, as Aaron reminded us, the very original syntax would have been something like

  main(argc, argv) char **argv {... }

由于原型,只不过是后来推出。这大概来了之后,每个人都记录了至少至少10小时追逐微妙(和不那么微妙)键入相关的错误

Since the "prototypes" were only introduced later. That came roughly after everyone had logged a minimum of at least 10 hours chasing subtle (and not so subtle) type-related bugs

这篇关于为什么ARGC一个'诠释'(而不是'无符号整数')?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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