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版)
声明
|
187
声明
malloc()
、
calloc()
和
realloc()
获得。关于动态进行存储分配的详细情况,请参见第
12
章。
11.6.1 静态存储周期
在所有函数的外面定义的对象,或者在函数内定义但使用存储类修饰符
static
的对象,
都具有静态存储周期。这包含具有内部或外部链接标识符的所有对象。
所有具有静态存储周期的对象,都是在程序开始运行之前就被事先创建和初始化的。它
们的生命期覆盖整个程序的运行过程。
11.6.2 线程存储周期
使用存储类修饰符
_Thread_local
定义的对象称为线程局部(
thread-local
)对象,它具
有线程存储周期。线程局部对象的存储周期覆盖整个线程的运行过程。每个线程都独自
拥有线程局部对象的实例,它在线程开始时初始化。
11.6.3 动态存储周期
定义在函数内且不具有存储类修饰符(或具有不必要的修饰符
auto
)的对象,则具有动
态存储周期。函数参数也具有动态存储周期。具有动态存储周期的对象通常简称为动态
变量(
automatic variable
)。
动态对象的生命期由该对象定义所处语句块的起始和终止大括号(
{}
)所决定。长度可
变的数组是个例外:长度可变数组的生命期始于其声明点,终于标识符的作用域(也就
是包含该声明的语句块末端,或当发生跳转时,跳转到了声明之前的程序点)。
每次程序运行进入一个语句块,该语句块动态对象的新实例就会被创建(可能同时被初
始化,如果该声明包含初始化器的话)。对于递归函数来说,理解这个特性很重要。
11.7 初始化
可以显式地赋予对象初始化值,做法是在对象定义时包含一个初始化器。定义对象时如 ...
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