编译此代码时:
#include <stdio.h>
enum Boolean
{
TRUE,
FALSE
};
int main(int argc, char **argv)
{
printf("%d", Boolean.TRUE);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我越来越:
错误:“布尔值”未声明(在此函数中首次使用)
我做错了什么?
在 C 中,您不能使用语法访问单独的枚举常量EnumType.SpecificEnum。你就说吧SpecificEnum。例如:
printf("%d", TRUE);
Run Code Online (Sandbox Code Playgroud)
当你写的时候
printf("%d", Boolean.TRUE);
Run Code Online (Sandbox Code Playgroud)
C 认为您正在尝试访问struct或union命名Boolean并访问该TRUE字段,因此会出现编译器错误。
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
2665 次 |
| 最近记录: |