我有一个由 VS2010 生成的通用 SDI 应用程序,我想用它来测试 WinUsb API。我安装了当前版本的 WDK。根据我在其他地方阅读的帖子,我应该能够将 VS2010 项目包含路径设置为指向 WDK 并添加包含 WinUsb.h 来执行此操作。所以我将它添加到 stdafx.h 如下
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <Winusb.h>
但是当我编译时出现错误
1>c:\winddk\7600.16385.1\inc\api\usb200.h(93): error C2332: 'struct' : missing tag name
1>c:\winddk\7600.16385.1\inc\api\usb200.h(93): error C2011: '<unnamed-tag>' : 'enum' type redefinition
1> c:\program files (x86)\microsoft sdks\windows\v7.0a\include\htmlhelp.h(331) : see declaration of '<unnamed-tag>'
1>c:\winddk\7600.16385.1\inc\api\usb200.h(93): error C2059: syntax error : 'constant'
1>c:\winddk\7600.16385.1\inc\api\usb200.h(93): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
它抱怨的结构是
typedef union _USB_HIGH_SPEED_MAXPACKET {
struct _MP {
USHORT MaxPacket:11; /* 0..10 */
USHORT HSmux:2; /* 11..12 */
USHORT Reserved:3; /* 13..15 */
};
USHORT us;
} USB_HIGH_SPEED_MAXPACKET, *PUSB_HIGH_SPEED_MAXPACKET;
并且 IDE 已将 _MP 下划线标记为红色。