更新时间:2021-08-19 22:50:35
假
和真正
是C ++的关键字,所以你不能把它们作为枚举
的标识符。
false
and true
are C++ keywords, so you can't use them as enum
identifiers.
在C他们不是关键字,让您的code将工作,但如果包括< stdbool.h>
那么它将无法编译,因为头定义假
和真正
为宏。
In C they are not keywords so your code will work, but if you include <stdbool.h>
then it will fail to compile because that header defines false
and true
as macros.
请注意,你可能不应该实现一个布尔类型自己。 C ++已经拥有了布尔
类型,如果您使用的是C99编译器,你可以包括 stdbool.h
。这会给你一个布尔
类型且具有假
和真正
值,类似于C ++。
Note that you probably shouldn't implement a boolean type yourself. C++ already has the bool
type, and if you are using a C99 compiler, you can include stdbool.h
. This will give you a bool
type that has false
and true
values, similar to C++.