GCC编译相关 - HeavyYuan/A-CD-Record-Management-System GitHub Wiki
编译命令: gcc -c -o main.o main.c
/* main.c */
#include <stdio.h>
int main()
{
int *p = foo();
}
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.(man gcc)
上述编译命令,没有报错foo undefined
去掉-c就会报错foo undefined。
解决办法也简单,对函数foo做下声明。