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

标签 c++ windows visual-studio-2010 boost-asio parity

我正在使用 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 中。作为一种解决方法,我更改了枚举名称。但是,我无法在 Internet 上找到与此问题相关的任何内容。有人可以帮我们解决这个问题吗?

最佳答案

它在 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/67739408/

相关文章:

c++ - CreateTexture2D 失败... (d3d)

windows - 为什么 power shell clear(或 cls)命令接受数字作为参数?

c++ 如何使用 utf8 十六进制代码打印 utf8 符号?

c++ - 在 Qt Creator Ubuntu 12.04 中设置 OpenCV

windows - 如何将 Eclipse 工作区和项目从 Windows 转移到 Linux 和 Mac

visual-studio-2010 - 在 Visual Studio 2010 中突出显示会杀死我的 Razor 语法

c++ - 为什么 visual studio 2010 寻找 __thiscall 而不是 __cdecl 调用约定?

c++ - 在基于 Visual Studio MFC 的应用程序中禁用事件处理程序

c++ - 可以合并代码覆盖率结果 (VC++)

c++ - 在 operator()() 中对具有状态和两个参数的函数对象使用 boost bind