The behavior of a C compiler with old-styled functions without prototypes

后端 未结 3 1928
自闭症患者
自闭症患者 2020-12-19 12:24

When my program consists of two files:

main.c

#include 

int main(void) { 
     printf(\"%lf\\n\",f());   
     return 0;
 }
         


        
3条回答
  •  不知归路
    2020-12-19 13:18

    Your first example never uses func.c so I'm not sure exactly what the compiler is doing about f() because it has no definition.

    In the second example, I don't know why you can't have two functions with different signatures, but you aren't calling the function you've defined. You call f() with no arguments, but the f you define takes an int which makes it a different function.

提交回复
热议问题