How many passes does the c compiler do?

int main() { int res; funcAdd(10,20); } int funcAdd(int a,int b) { return a+b; } 

In the above program, funcAdd () does not recognize the main thing, because it is defined after main, and there is no declaration at the beginning. If the C compiler performed 2 passes of the program, this should not be a problem, since it will know that the funcAdd () function is defined in the second pass. Does this mean that C is a single-pass compiler? Please clarify my doubts.

+1
source share
2 answers

The C language does not indicate how many passes the compiler should go through. However, he / does / indicates that functions must be declared before they are used. Therefore, your code is invalid, no matter how long the compiler goes through.

+11
source

Your arguments are invalid. The C compiler can do as many passes as it wants, but in this case it should still return an error, because the standard says this.

+2
source

Source: https://habr.com/ru/post/986322/


All Articles