Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

USB build errors

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US
I created a new project in VC2008. I added nothing to the code except these statements:

Code:
extern "C" {
#include <usb.h>
#include <usbiodef.h>
#include <usbioctl.h>
#include <usbprint.h>
#include <setupapi.h>
#include <devguid.h>
#include <wdmguid.h>
#include <InitGuid.h>
}

/*
  This define is required so that the GUID_DEVINTERFACE_USBPRINT variabl is
    declared and intialized as static locally, since windows does not
    include it in any of its libraries.
*/

#define SS_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
	static const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
	
//	SS_DEFINE_GUID(GUID_DEVINTERFACE_USBPRINT, 0x4d36e979, 0xe325, 0x11ce, 0xbf,
// 		         0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18);

	SS_DEFINE_GUID(GUID_DEVINTERFACE_USBPRINT, 0x28d78fad, 0x5a12, 0x11d1, 0xae,
		         0x5b, 0x00, 0x00, 0xf8, 0x03, 0xa8, 0xc2);

/*
Identifier GUID_DEVINTERFACE_USB_DEVICE 
Class GUID {A5DCBF10-6530-11D2-901F-00C04FB951ED} 
*/

//#define SS_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
//	static const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
	
	SS_DEFINE_GUID(GUID_DEVINTERFACE_USBDEVICE, 0xa5dcbf10, 0x6530, 0x11d2, 0x90,
		         0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed);

When I build it I get these errors in the usb200.h file:

error C2332: 'struct':missing tag name
error C2011:'<unnamed-tag>':'enum' type redefinition
error C2059:syntax error:'constant'
error C2334: unexpectoed token(s) preceding '{'; skipping apparent function body

These all apply to line 91 of usb200.h. This is the code:

Code:
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;

Line 91 is: struct _MP {.

I have the same code in another project that works fine. I don't remember if I had to do anything else to make it work.

Thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
It needs a tag name (like mp)
Code:
typedef union _USB_HIGH_SPEED_MAXPACKET {
    struct _MP {
        USHORT   MaxPacket:11;  /* 0..10 */
        USHORT   HSmux:2;        /* 11..12 */
        USHORT   Reserved:3;    /* 13..15 */
    } [COLOR=red][b]mp[/b][/color];
    USHORT us;
  } USB_HIGH_SPEED_MAXPACKET, *PUSB_HIGH_SPEED_MAXPACKET;
 
Thanks xwb,

Sorry about not getting back earlier. Been real busy around here.

The USB200.h is not my file. I believe it's a Microsoft file. But I did find out what I did before. I had to add this line to the stdafx.h file:

Code:
#undef _MP

I don't remember where I got that answer. And I haven't had the time to see where _MP was #defined in the first place, and what it is used for other than the USB function.

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top