未声明枚举? [英] Undeclared enum?

查看:159
本文介绍了未声明枚举?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写此code:

#include <stdio.h>

enum Boolean
{
    TRUE,
    FALSE
};

int main(int argc, char **argv)
{
    printf("%d", Boolean.TRUE);

    return 0;
}

我收到:

错误:'布尔'未声明(第一次使用此功能使用)

error: 'Boolean' undeclared (first use in this function)

我在做什么错了?

推荐答案

在C,你不访问使用单独的语法枚举常量 EnumType.SpecificEnum 。你刚才说 SpecificEnum 。例如:

In C, you don't access individually enumerated constants using the syntax EnumType.SpecificEnum. You just say SpecificEnum. For example:

printf("%d", TRUE);

当你写

printf("%d", Boolean.TRUE);

ç认为你想转到结构联盟名为布尔并访问 TRUE 字段,因此编译器错误。

C thinks that you're trying to go to the struct or union named Boolean and access the TRUE field, hence the compiler error.

希望这有助于!

这篇关于未声明枚举?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆