已经解决:
当主体文件 没有声明时(即没有包含的头文件)就会报错;对其的一些**猜测**:
#include
//#include"max.h"
max.h ↓int max(int a,int b);
max.c ↓int max(int a,int b)
{ if(a>b){
return a;
}else{
return b;
}
}
没有包含头文件,也就是没有声明函数,但之前进行 了 compile and assemble. 生成 max.o 文件gcc max.c -c -o max.o
于是gcc max.o max.c -o outfilegcc main.c max.o -o out
警告提示:warning: implicit declaration of function ‘max’
但成功生成 文件 out
以上是没有 定义 函数。
如果导入 头文件 (定义了 max 函数),或着直接在 main 中定义max函数,再和 *.o 文件 链接编译,gcc main.c max.o -o out
就不会出现 警告和错误。