PARITY_NONE C++ Windows 中的关键字? [英] PARITY_NONE a keyword in C++ Windows?
问题描述
我正在使用 boost 编写一个串行库,我有一个枚举:
I am writing a serial library using boost and I have an enum:
enum parity_t { PARITY_NONE, PARITY_ODD, PARITY_EVEN };
我收到如下错误:
错误 1 错误 C2059:语法错误:'('
Error 1 error C2059: syntax error : '('
我无法弄清楚是什么问题.然后我和我的朋友尝试了:
I couldn't figure out what the issue was. Then my friend and I tried:
void PARITY_NONE();
我们得到了这些错误:
错误 1 错误 C2143:语法错误:在 'constant' 之前缺少 ')'
Error 1 error C2143: syntax error : missing ')' before 'constant'
错误 2 错误 C2143:语法错误:缺少 ';'在常量"之前
Error 2 error C2143: syntax error : missing ';' before 'constant'
错误 3 错误 C2182:'WORD':非法使用类型 'void'
Error 3 error C2182: 'WORD' : illegal use of type 'void'
错误 4 错误 C2059:语法错误:')'
Error 4 error C2059: syntax error : ')'
我包含了 boost asio,我认为它在某处包含了 Windows 串行 API.这仅发生在 Windows 中.作为一种解决方法,我更改了枚举名称.但是,我无法在 Internet 上找到与此问题相关的任何内容.有人能帮我们解决这个问题吗?
I am including boost asio, which I figure is including the Windows serial api somewhere. This only occurs in Windows. As a work around I have changed my enumeration names. I cannot, however, find anything related to this issue on the internet. Can someone help us figure this out?
推荐答案
winbase.h 中定义:
It's defined in winbase.h:
//
// Settable Stop and Parity bits.
//
#define STOPBITS_10 ((WORD)0x0001)
#define STOPBITS_15 ((WORD)0x0002)
#define STOPBITS_20 ((WORD)0x0004)
#define PARITY_NONE ((WORD)0x0100)
#define PARITY_ODD ((WORD)0x0200)
#define PARITY_EVEN ((WORD)0x0400)
#define PARITY_MARK ((WORD)0x0800)
#define PARITY_SPACE ((WORD)0x1000)
#undef
在创建枚举之前.
这篇关于PARITY_NONE C++ Windows 中的关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!