gpt4 book ai didi

c - 运行时限制和编译时间限制的定义是什么?

转载 作者:行者123 更新时间:2023-11-30 19:57:10 25 4
gpt4 key购买 nike

来自APUE

Many of these have been hard coded into programs or were determined using ad hoc techniques. With the various standardization efforts that we’ve described, more portable methods are now provided to determine these magic numbers and implementation-defined limits, greatly improving the portability of software written for the UNIX environment.

Two types of limits are needed:

  1. Compile-time limits (e.g., what’s the largest value of a short integer?)

  2. Runtime limits (e.g., how many bytes in a filename?)

Compile-time limits can be defined in headers that any program can include at compile time. But runtime limits require the process to call a function to obtain the limit’s value.

...

To further confuse things, if a particular runtime limit does not vary on a given system, it can be defined statically in a header. If it is not defined in a header, however, the application must call one of the three conf functions (which we describe shortly) to determine its value at runtime.

首先,在我看来,编译时限制被定义为可以在 header 中定义的限制,而运行时限制则被定义为不能在 header 中定义的限制。

那么在我看来,运行时间限制也可以在 header 中定义。

那么运行时限制和编译时间限制的定义是什么?

最佳答案

您原来的定义已经是正确的。如果您能够使用 header 中的准确限制,那么这意味着对于该系统,这是编译时限制。这可能是某些其他系统上的运行时限制,在这种情况下, header 不会提供静态定义。

或者,您可以将任何存在函数的东西视为运行时限制;当然,在某些系统上它实际上是一个常量值,但是对于可移植代码,您无论如何都需要使用该函数,因此它是一个运行时限制,在某些系统上检查恰好非常便宜(其中该函数可以是定义为返回静态值)。

重点是,没有一个确切的答案;有些东西是有条件运行时或编译时,具体取决于系统,有些东西总是编译时,有些东西总是运行时。这是维恩图。

关于c - 运行时限制和编译时间限制的定义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52188869/

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