【发布时间】:2013-06-03 14:30:02
【问题描述】:
我想做以下事情:
parser.h
#ifndef WS_PARSER_H
#define WS_PARSER_H
#include <stdin.h>
#include <stdbool.h>
typedef enum {
FIN = 0x80;
RSV1 = 0x40
/* ... */
} ws_flags;
#endif
parser.c
#ifndef WS_PARSER
#define WS_PARSER
#include "parser.h"
ws_read_fin_flag(unsigned char * chunk) {
return (bool) chunk[0] & WS_FLAGS.FIN;
}
#endif
不幸的是,我知道 FIN 是一个未声明的标识符。
我做错了什么?
更新:
全局枚举的约定是什么?
typedef enum {} WS_FLAGS;
【问题讨论】:
-
很难看到错字。您应该使用像样的 IDE,以便在您键入时突出显示这些拼写错误。尝试日食。
-
这意味着您可以在没有枚举限定符的情况下引用
WS_FLAGS,例如定义WS_FLAGS flag=FIN;类型的变量,不要从答案中纠正您的问题 -
@GrijeshChauhan 这符合约定吗?还是我应该使用宏图