In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to build your own function library". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
1. What does the gcc compiler do?
As the saying goes, know yourself and know your enemy, and you will never be defeated in a hundred battles.
First of all, with an example to take you to understand the gcc compilation process.
//main.cint sum (int *a, int n);int array[2] = {1, 2};int main(){ int val = sum(array, 2); return val;}//sum.cint sum(int *a, int n){ int i, s = 0; for(i=0; i < n; i++){ s += a[i]; } return s;}
Suppose a project consists of two source programs. The main function initializes an array of integers and then calls a sum function defined in another file to sum the elements of the array.
Normally, we would type gcc -Og -o prog main.c sum.c directly from the command line to compile the binary executable ELF object file prog directly. So what did the gcc do in the meantime?
(Note: You can add the parameter-v to the gcc command to observe the working process.)
See photo
static link
1.1 cpp pretreatment cpp main.c -o main.i
The preprocessor cpp translates the source code main.c into an ASCII intermediate file main.i.
1.2 ccl -Og main.i -o main.s
The C compiler ccl translates the intermediate file into an ASCII assembly language file main.s.
Note: -O parameter selection optimization level, from low to high g
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.