多少遍没有一个C编译器吗? [英] How many passes does a c compiler do?

查看:125
本文介绍了多少遍没有一个C编译器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int main()
{
    int res;
    funcAdd(10,20);
}

int funcAdd(int a,int b)
{
    return a+b;
}

在上述程序中,主要不识别funcAdd(),因为它是经过主定义并且在开始时没有声明。如果C编译器那样通过2次的节目,则它必须不是一个问题,因为它会知道函数funcAdd()被在第二遍进行定义。这是否意味着C是一遍编译器?请澄清我的疑问。

In the above program, main does not recognize funcAdd() since it is defined after main and there is no declaration in the beginning. If C compiler did 2 passes of a program then this must not be an issue since it will know the function funcAdd() is be defined in the second pass. Does this mean C is one pass compiler? Kindly clarify my doubt.

推荐答案

C语言不指定编译器必须有多少通过服用。但是,/没有/指定要使用之前的功能必须申报。因此,您的code是无效的,无论编译器多少让传递

The C language doesn't specify how many passes a compiler must take. However, it /does/ specify that functions must be declared before they are used. Hence, your code is invalid, regardless of how many passes the compiler makes.

这篇关于多少遍没有一个C编译器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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