gpt4 book ai didi

c - 哪些是可执行语句?

转载 作者:太空狗 更新时间:2023-10-29 16:05:47 25 4
gpt4 key购买 nike

很多次,四处阅读,我发现了这样的定义:

Definitions are not executable statements. They’re messages to the compiler. For example, the definition int i; simply tells the compiler the type of variable i and instructs the compiler to reserve space in memory for the variable.

像这样的陈述总是让我感到困惑,因为,恕我直言,一切似乎都“需要采取行动”。例如,在这种情况下,计算机必须执行一些操作来分配一些内存。

那么这些陈述究竟指的是什么?

最佳答案

C 语言识别局部声明和语句 之间的相似性。这体现在

6.8 Statements and blocks

3 A block allows a set of declarations and statements to be grouped into one syntactic unit. The initializers of objects that have automatic storage duration, and the variable length array declarators of ordinary identifiers with block scope, are evaluated and the values are stored in the objects (including storing an indeterminate value in objects without an initializer) each time the declaration is reached in the order of execution, as if it were a statement, and within each declaration in the order that declarators appear.

但是,在形式上,声明不属于 C 中的语句。

请注意,局部声明的“语句式”属性实际上与初始化相关联。至于内存分配......该语言实际上并未指定内存分配的确切时间。它不一定发生在控制权越过定义时。

外部定义绝对不是语句,因为它们不涉及控制流。

关于c - 哪些是可执行语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42054763/

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