gpt4 book ai didi

c - "total function"是什么?

转载 作者:太空宇宙 更新时间:2023-11-04 00:30:42 25 4
gpt4 key购买 nike

在“JPL Institutional Coding Standard for the C programming Language”中,我在规则 15(第 14 页)的正下方找到了以下句子:

“这符合使用总函数优于非总函数的原则。”。

我以前没听说过“总函数”。这是什么?你能给我一些总功能的例子吗?

下面是 JPL 文档的链接。

http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf

最佳答案

文档的下一句对此进行了解释:

A total function is setup to handle all possible input values, not just those parameter values that are expected when the software functions normally.

我认为它最初是一个数学术语。 total 函数 是对所有可能的参数值都具有明确定义的行为的函数。

非完整函数的一个例子是 strlen(),如果它的参数是空指针、无效指针或指向没有空值的数组的指针,则它具有未定义的行为'\0' 字符。 (并且没有真正的方法,至少在可移植的 C 中,使 strlen() 检测并处理所有可能的无效参数。)

total 函数,在文档中使用的意义上,要么为所有可能的输入返回有意义的结果,要么检测任何无效输入并以某种明确定义的方式报告错误。

关于c - "total function"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19647180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com