声明的主要原型 [英] Declare main prototype
本文介绍了声明的主要原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何理由,我从来没有看到主要的原型在C程序中声明,例如:
INT主(INT ARGC,CHAR *的argv []);INT主(INT ARGC,CHAR *的argv [])
{
返回0;
}
似乎总是不一致。
解决方案
C语言标准草案的 n1256 :
5.1.2.2.1程序启动的搜索结果
1名为在程序启动时的功能被命名为主
。 的实施没有声明
原型此功能的。它应INT
的返回类型,并没有被定义
参数:搜索结果搜索结果
INT主要(无效){/ * ... * /}
或者两个参数(这里称为ARGC
和的argv
,虽然任何名称可能是
使用,因为它们是局部的,其中它们被声明)的功能:搜索结果搜索结果
INT主(INT ARGC,CHAR *的argv []){/ * ... * /}
或同等学历; 9)或一些其他实现定义的方式块引用>重点煤矿。
Is there any reason why I never see main's prototype declared in C programs, ie:
int main(int argc, char* argv[]); int main(int argc, char* argv[]) { return 0; }
Always seemed inconsistent..
解决方案C language standard, draft n1256:
5.1.2.2.1 Program startup
1 The function called at program startup is namedmain
. The implementation declares no prototype for this function. It shall be defined with a return type ofint
and with no parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here asargc
andargv
, though any names may be used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;9) or in some other implementation-defined manner.Emphasis mine.
这篇关于声明的主要原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文