Skip to main content

C1901

switch表达式不得是基本布尔类型

Category: Required

Decidability: Decidable

Scope: Single Translation Unit

依据

C语言标准规定 switch 语句的控制表达式是整数类型。因为用于实现布尔值的是整数类型,因此可能出现用布尔表达式控制 switch 语句的情况。而这时使用 if-else 更加合适。

登录查看完整文章