gpt4 book ai didi

c - ANSI C 中是否定义了枚举加法?

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

是否保证此代码后的stateLX_DONE

enum lx_state { LX_START, LX_MIDDLE, LX_DONE };

enum lx_state state = LX_START;
++state;
++state;

最佳答案

是的,C 标准说,在 6.7.2.2/3 中,

Each subsequent enumerator with no = defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant

关于c - ANSI C 中是否定义了枚举加法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6347376/

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