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版)
278
|
第
16
章
程序自定义函数或其他链接库函数冲突。如果在包含头文件之前,没有定义宏
__STDC_
WANT_LIB_EXT1__
,则对应的安全函数可能有效也可能无效,这取决于特定的编译器。
16.2.2 运行约束
在边界检查函数中指定数组大小的参数,其类型为
rsize_t
。该类型在头文件
stddef.h
中
定义,且等于
size_t
。然而,
rsize_t
对于变量的值有一个特殊的限制:类型
rsize_t
变
量的赋值不得大于宏值
RSIZE_MAX
。传递数组长度大于
RSIZE_MAX
的参数给边界检查函数
会导致错误。这种限制可以检测出由负数转换为无符号类型所引发的错误,因为这种转
换会导致非常大的正数。
除了边界检查,安全函数还执行其他测试。例如,它们测试作为参数传递的指针是
否非空。对于函数成功执行所须满足的所有条件称之为函数的运行约束(
runtime
constraint
)。
如果违反安全函数的运行约束,目标对象将维持不变,函数调用运行约束处理器
(
runtime constraint handler
),向其传递一个返回值和错误消息。处理器通过调用
abort()
终
止程序,或者返回到调用它的安全函数。程序可以通过调用
set_constraint_
handler_s()
,采用另外的标准处理器或自定义的函数,以取代默认的运行约束处理
器。详细信息请参阅第
18
章中函数
set_constraint_handler_s()
的说明
。
安全函数的返回值指示是否发生了错误。许多安全函数具有类型为
errno_t
的返回值。 ...
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

数据库系统内幕

数据库系统内幕

Alex Petrov
精通機器學習

精通機器學習

Aurélien Géron
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
算法精讲视频课程:24篇系列讲座

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

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

Publisher Resources

ISBN: 9787111562207