程序的编译过程 Pre-ProcessingCompilingAssermblingLinking Pre-Processing 处理源文件(.c, .C, .h)中的#ifdef, #include和#define gcc -E test.c -o test.i Compiling 把中间文件转换程汇编文件 gcc -s test.i -o test.s Assermbling 将汇编文件转换程二进制代码文件 gcc -c test.s -o test.o Linking 将输入的二进制机器代码文件(与其他机器代码文件和库文件)汇集程一个可执行的二进制代码文件 gcc test.o -c test 可以简化为 gcc -c test.c -o test.o gcc test.o -o test # 或者 gcc test.c -o test # 最后执行 ./test 事例 #include<stdio.h> int main() { int i, j; long sum = 0; for (i = 1; i <= 10; i++) { int total = 1; for (j = 1; j <= i; j++) total = total * j; sum = sum + total; } printf("1! + 2! + 3! + ... + 10! = %ld\n", sum); return 0; }