Skip to Content
C语言核心技术(原书第2版)
book

C语言核心技术(原书第2版)

by Peter Prinz, Tony Crawford
August 2017
Intermediate to advanced
798 pages
17h 44m
Chinese
China Machine Press
Content preview from C语言核心技术(原书第2版)
26
|
第
1
章
}
x *=2
;
//
这里,
x
再次指的是
long
变量
/*...*/
}
在这个例子中,声明在
main()
函数内的
long
变量
x
,会隐藏函数外部类型为
double
的变
量
x
。因此,在
main()
中无法直接访问
double
变量
x
。而且,在
if
条件语句块中,
x
指的
是新声明的
float
变量,这里又隐藏了条件语句外部的
long
变量
x
。
1.7 C编译器运行原理
一旦使用文本编辑器编写完源代码,就可以调用
C
编译器把源代码转换成机器码。编译
器对翻译单元进行处理,一个翻译单元由一个源代码文件以及所有通过
#include
命令引
用的头文件组成。如果编译器在翻译单元内没有发现错误,则会生成包含了对应机器码
的目标文件(
object file
)。目标文件的扩展名通常为
.o
或
.obj
。除此之外,编译器也可
以产生一个汇编器列表(请参见第
19
章)。
目标文件也称为模块(
module
)。一个链接库(例如
C
标准库)包含了多个编译好的可
以快速获取的模块,模块里有许多标准函数。
编译器将一个
C
程序的每个翻译单元(指的是每个源代码文件,以及其所包含的所有头
文件)翻译成一个独立的目标文件。然后编译器调用链接器(
linker
)将所有的目标文件
和所用到的链接库函数结合起来,成为一个可执行文件(
executable file
)。图
1-1
展示了
一个程序从几个源代码文件和链接库编译和链接的过程。可执行文件内也包含了所有供
目标操作系统加载与启动该程序的信息。
1.7.1 C编译器的编译阶段 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787111562207