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版)
声明
|
185
声明
•
在第
15
章中将介绍的预处理器命令
#error
,当命令
#if
指定的条件满足时,它使得预
处理器退出,并产生一个错误消息。
11.5 标识符的链接
在多个翻译单元内被声明的标识符,或者在同一个翻译单元内被声明多次的标识符,可
以在每个实例中指向相同的对象或函数。标识符范围在翻译单元内还是翻译单元之间,
是由该标识符的链接(
linkage
)决定的。这也阐述了一个事实,不同源代码文件中的标
识符,如果需要让它们指向共同的对象,需要采用链接方式。
C
语言的标识符具有外部链接(
external linkage
)、内部链接(
internal linkage
)或无链
接(
no linkage
)三种链接方式。链接方式由声明的位置和存储类修饰符决定。只有对象
和函数标识符可以有外部或内部链接。
11.5.1 外部链接
具有外部链接的标识符,表示整个程序都引用相同的函数或对象。编译器会将这种标识
符交给链接器,由链接器解析它们,并且把其他翻译单元和链接库中出现的与它们相同
的标识符链接起来。
在声明函数和对象标识符的时候,如果使用存储类修饰符
extern
,那么就具有外部链
接。唯一的例外是:如果标识符已经被声明为内部链接,在第一次声明的作用域内再进
行第二次声明,无法将该标识符的链接变成外部链接。
对于没有使用存储类修饰符的函数声明,编译器会默认它们具有
extern
修饰符。类似
地,任何对象标识符只要是声明在所有函数的外面,并且没有存储类修饰符,则默认地
具有外部链接。
11.5.2 内部链接
具有内部链接的标识符,表示在该翻译单元内所引用的都是相同的对象或函数。该标识 ...
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