gpt4 book ai didi

c++ - PARITY_NONE C++ Windows 中的关键字?

转载 作者:太空宇宙 更新时间:2023-11-04 15:09:25 25 4
gpt4 key购买 nike

我正在使用 boost 编写一个串行库并且我有一个枚举:

enum parity_t { PARITY_NONE, PARITY_ODD, PARITY_EVEN };

我收到如下错误:

Error 1 error C2059: syntax error : '('

我无法弄清楚问题出在哪里。然后我和我的 friend 尝试了:

void PARITY_NONE();

我们得到了这些错误:

Error 1 error C2143: syntax error : missing ')' before 'constant'

Error 2 error C2143: syntax error : missing ';' before 'constant'

Error 3 error C2182: 'WORD' : illegal use of type 'void'

Error 4 error C2059: syntax error : ')'

我包括了 boost asio,我认为它在某处包括了 Windows 串行 api。这仅发生在 Windows 中。作为解决方法,我更改了我的枚举名称。但是,我无法在互联网上找到与此问题相关的任何信息。有人可以帮我们解决这个问题吗?

最佳答案

在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 在创建您的枚举之前。

关于c++ - PARITY_NONE C++ Windows 中的关键字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5395303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com