×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

USB build errors

USB build errors

USB build errors

(OP)
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.

RE: USB build errors

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 */
    } mp;
    USHORT us;
  } USB_HIGH_SPEED_MAXPACKET, *PUSB_HIGH_SPEED_MAXPACKET;

RE: USB build errors

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close