c++ - C语言中多文件函数调用是否可以不加extern?

浏览:44日期:2023-04-15

问题描述

以下两段代码,为什么gcc在去掉extern声明后仍然可以正常编译和运行(g++没通过),这是C允许的语法还是gcc对编译过程有自己特殊的处理方式?main.c和function.c处于同一文件下main.c

#include<stdio.h>//extern void myFunction();int main(){ printf('this is a testn'); myFunction(); return 0;}

function.c

#include<stdio.h>void myFunction(){ printf('hahah');}

问题解答

回答1:

https://segmentfault.com/q/10...

相关文章: