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'
Have you defined "BYTE" somehow?
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_ ; / ## /
#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