当前位置:网站首页>GCC introduction
GCC introduction
2022-06-28 11:01:00 【MoyangCitta】
View version gcc/g++ -v/--version
gcc Workflow
- precompile ( Source code :.c .c++ .h):gcc -E main.c -o main.i
- compile ( Source code after preprocessing :.i):gcc -S main.i -o main.s
- assembly ( Assembly code :.s):gcc -c main.s -o main.o
- link ( Object code :.o, Startup code , Library code , Other object codes ):gcc main.o -o main
- precompile : Delete all “#define”, And expand all macro definitions , Process all conditional precompiled instructions at the same time , Then process “#include” Preprocessing instruction , Insert the included file into the location of the precompiled instruction , Delete all comments , Add line number and filename ID , The compiler generates symbol information for debugging and displays line numbers when compiling errors and warnings , Last but not least “#pragma” Compiler Directives , Its function is to set the state of the compiler or instruct the compiler to complete some specific actions .
- Compile phase : Lexical analysis 、 Syntax analysis 、 Semantic analysis , Code optimization , Summary symbol , Generate assembly code .
- Assembly stage : Translate assembly instructions into binary format , Generate each section, Generate symbol table .
- Link phase : Merge each section, adjustment section Initial displacement and segment size , Merge symbol tables , Perform symbol parsing , Assign virtual addresses to symbols , Symbol repositioning .
gcc and g++ difference
- The suffix is .c Of ,gcc Think of it as C Program , and g++ As if c++ Program
- The suffix is .cpp Of , Both of them will think that C++ Program
- Compile phase ,g++ Would call gcc, But in the link phase , Because of the need C++ The library of , So here we need to use g++ To complete the link .
- about “_cplusplus” macro , It indicates that the compiler will press C still C++ Grammar to explain , therefore , If the suffix is .c, And adopt gcc compiler , Then the macro is undefined , otherwise , Is defined .
gcc Parameter options
| Compilation options | explain |
| -o test test.c / test.c -o test | take test.c Compile to executable test |
| -I directory | Appoint include Search directory containing files |
| -g | Generate debug information at compile time |
| -D | Specify a macro at compile time |
| -w | No warning messages are generated |
| -W | Generate all warning messages |
| -On | Optimization options ,-O0 No optimization ,-O1 Is the default value ,-O3 The highest level of optimization |
| -l | When the program is compiled , Specify the library to use |
| -L | Specify when compiling , Search the path to the library |
| -fPIC/fpic | Generate location independent code |
| -shared | Generate shared object file , It's usually used when building shared libraries |
| -std | Appoint C standard |
边栏推荐
- 知道 Redis RDB 这些细节,可以少踩很多坑
- Katalon当中的使用循环for、while和if...else、break、continue
- Katalon framework tests web (XX) custom keywords and upload pop-up operations
- Word、PDF、TXT文件实现全文内容检索需要用什么方法?
- 【monkey】monkey测试入门
- Wealth management for programmers
- Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
- 时间戳和date转换「建议收藏」
- Compression and decompression
- Knowing the details of redis RDB, you can step on many holes less
猜你喜欢

【实操】Appium Settings app is not running after 5000ms
![[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)](/img/02/4dbd97c8b8df1c96b7c8e1460aeda2.png)
[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)

AGCO AI frontier promotion (6.28)

sentinel

论文阅读 (59):Keyword-Based Diverse Image Retrieval with Variational Multiple Instance Graph

Yann Lecun's new paper: the road to building automatic agents

还在用 SimpleDateFormat 做时间格式化?小心项目崩掉!

JS基础3

Katalon全局变量在TestObject引用

MySQL(一)
随机推荐
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错
MySQL(二)
Six fusion positioning technologies in wireless communication application of Internet of things
Convert the file URL in the browser to a file stream
Hystrix 部署
壓縮解壓
Katalon framework tests web (XX) custom keywords and upload pop-up operations
什么是主链系统?
远程登录sshd服务
选择哪种编程语言,会吸引优秀的人才?
Katalon当中的debug调试
Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
datetime与logging模块
JS基础1-JS引入与运算符
东方财富手机股票开户哪个券商更安全更方便?
Installing MySQL database (CentOS) in Linux source code
【剑指Offer】49. 丑数
Xshell和Xftp使用教程
JS基础5
建立自己的网站(11)