bod*_*ser 0 c enums const header
我想做以下事情:
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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
不幸的是,我得到的FIN是未声明的标识符.
我做错了什么?
更新:
全球枚举的惯例是什么?
typedef enum {} WS_FLAGS;
Run Code Online (Sandbox Code Playgroud)
#ifndef WS_PARSER_H
#define WS_PARSER_H
#include <stdin.h>
#include <stdbool.h>
typedef enum {
FIN = 0x80,
RSV1 = 0x40,
/* ... */
} ws_flags;
#endif
Run Code Online (Sandbox Code Playgroud)
这是一个,
而不是;
.