[2018.04.28] C with Pointer
Posted f4k1r
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[2018.04.28] C with Pointer相关的知识,希望对你有一定的参考价值。
gcc -c x1.c x2.c 只编译不连接
gcc x1.c x2.c -o output_filename 编译后连接成可执行文件
gcc x1.o x2.o -o output_filename 连接成可执行文件
1、例如,源文件 tmp.c,单独编译compile并连接link
gcc tmp.c -o tmp.exe,这样中间生成的目标文件在链接过后删除。
好像不能写成gcc -c tmp.c -o tmp.exe 因为-c 是只编译不链接。
2、比如多个文件 B.c A.c A.h,其中B.c为main方法入口源文件,
B.c源文件如下
1 #include <stdio.h> 2 #include "A.h" 3 4 int main(void){ 5 printA(); 6 return 0; 7 }
A.c源文件如下
#include <stdio.h> #include "A.h" void printA(){ printf("fuck"); }
A.h头文件如下
void printA();
这个时候B.c要用到A.h头文件声明的、A.c定义的printA函数,这样的编译链接需要:
gcc -c B.c A.c 编译生成各自的目标文件A.o和B.o
gcc B.o A.o -o main 链接生成main.exe可执行文件
./main 运行main.exe
或者直接用gcc A.c B.c -o main多文件编译链接,生成可执行文件main
以上是关于[2018.04.28] C with Pointer的主要内容,如果未能解决你的问题,请参考以下文章
1023 Have Fun with Numbers (20)(20 point(s))
An entry point cannot be marked with the 'async' modifier
尝试打开已链接到 Share Point with Access 2013 的表时,Access 2007 出错
[Ramda] Eliminate Function Arguments (Point-Free Style) with Ramda's Converge
A program to print Fahrenheit-Celsius table with floating-point values
LeetCode 528. Random Pick with Weight / 497. Random Point in Non-overlapping Rectangles