This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cypress EZUSB

when i try writing a simply code for EZUSB,i use inlude :"EZRegs.h", a error missing ";".
But i don't Why, i try clear a ";" as comment but the Debug has this error.
Help me, please!

#ifdef ALLOCATE_EXTERN
#define EXTERN
#define _AT_ _at_
#else
#define EXTERN extern
#define _AT_ ; / ## /
#endif

/* Register Assignments 3/18/99 TPM */
EXTERN xdata volatile BYTE OUT7BUF[64] _AT_ 0x7B40;
EXTERN xdata volatile BYTE IN7BUF[64] _AT_ 0x7B80;
EXTERN xdata volatile BYTE OUT6BUF[64] _AT_ 0x7BC0;
EXTERN xdata volatile BYTE IN6BUF[64] _AT_ 0x7C00;
EXTERN xdata volatile BYTE OUT5BUF[64] _AT_ 0x7C40;
EXTERN xdata volatile BYTE IN5BUF[64] _AT_ 0x7C80;
EXTERN xdata volatile BYTE OUT4BUF[64] _AT_ 0x7CC0;
EXTERN xdata volatile BYTE IN4BUF[64] _AT_ 0x7D00;
>>>>>>Error

EZREGS.H(47): error C129: missing ';' before 'OUT7BUF'

  • First, isn't the EZUSB an 8051 derivative; not 80251?
    Probably nothing to do with this specific problem, but using the wrong tools is never a good idea...

    #define _AT_ ; / ## /
    What are you trying to do here?
    Looks like some kind of cunning token-pasting?

    Are you sure that it's working as you intended?
    Have you examined the preprocessor output to check?

    See Andy's Handy Hint for Debugging Preprocessor Problems:

    http://www.8052.com/forum/read.phtml?id=29152

    Or try something like this instead:
    #ifdef ALLOCATE_EXTERN
    #define EXTERN
    #define _AT_(address) _at_ address
    #else
    #define EXTERN extern
    #define _AT_(address)
    #endif

  • thats the std way how the cypress headers work. One C File defines ALLOCATE_EXTERN and includes the header the other c files don't define ALLOCATE_EXTERN

    so you get two different declarations:

    extern xdata volatile BYTE OUT7BUF[64];//0x7B40

    and

    xdata volatile BYTE OUT7BUF[64] _at_ 0x7B40;

    this how cypress worked around multible definitions

    Thomas

  • this how cypress worked around multible definitions

    ... and it shows their knowledge of the preprocessor is in the dangerous region somewhere between decent and really competent --- the region where people think they know what they're doing and begin to make serious mistakes.

    If they were only decently competent, but knew their limits, they would have given up before inventing this atrocity, and have done it the simple way: by actually writing the declaration where declarations should go, and the definition where definitions should go, and screw the "overhead" of having to type the declaration twice.

    If they really knew what they're doing, they wouldn't believe that a // comment operator generated by token pasting will work as they intend it to, and found an actual working solution, like

    #ifdef INCLUDED_TO_DEFINE
    # define SYMBOL(decl,init) decl init
    #else
    # define SYMBOL(decl,init) extern decl
    #endif

  • ... and it shows their knowledge of the preprocessor is in the dangerous region somewhere between decent and really competent --- the region where people think they know what they're doing and begin to make serious mistakes.

    Actually I think it was Anchor which did that parts...
    The c examples were even stranger. Cypress did never changed that.
    I did it my own way using a struct.

    Thomas