gpt4 book ai didi

c - C 标准是否要求编译时常量表达式求值?

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

例如是

static int a[1+1];

有效的标准 C?对于标准的部分或所有版本?

我对编译器是否可以处理它不感兴趣,但它是否是标准 C 的一部分。

最佳答案

C11,§6.6:

A constant expression can be evaluated during translation rather than runtime, and accordingly may be used in any place that a constant may be.

所以是的,简单的常量折叠是强制性的,这个片段是有效的标准 C。

关于c - C 标准是否要求编译时常量表达式求值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15789065/

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