I have a piece of C code in a header file used for a 8051 microcontroller as below -
#define Sfr(x, y) sfr x = y
#define Sbit(x, y, z) sbit x = y^z
#define Sfr16(x,y) sfr16 x = y
/*----------------------------------------*/
/* Include file for 8051 SFR Definitions */
/*----------------------------------------*/
/* BYTE Register */
Sfr(P0 , 0x80);
Sbit (P0_7 , 0x80, 7);
Sbit (P0_6 , 0x80, 6);
When compiling, I get the error line 17: syntax error, expecting declaration
.
Any mistake in the usage of the macro?
Each time you use any of your macros, it declares the same variable 'x' over and over.There's
alsono evidence that the compiler knows whatsfir
orsbit
orsfr16
are.