We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
One HAL head file: /**********************************/ #ifndef __HAL_H__ #define __HAL_H__ #define DATA_BUS P0 // sbit MCU_TXD = P1^0; // sbit MCU_RXD = P1^1; // sbit MCU_NC = P1^2; sbit D12_A0 = P1^3; sbit MCU_INT1 = P1^4; // sbit MCU_RST = P1^5; sbit WR_N = P1^6; sbit RD_N = P1^7; sbit LED1 = P3^0; sbit LED2 = P3^1; #define A0_COMMAND D12_A0=1 #define A0_DATA D12_A0=0 #define DATABUS_READ(x) DATA_BUS = 0xFF; D12_RD_N = 0; x = DATA_BUS; D12_RD_N = 1 #define DATABUS_WRITE(x) D12_WR_N = 0; DATA_BUS = x; D12_WR_N = 1 #define DISABLE EA=0 #define ENABLE EA=1 #endif /**********************************/ While compiling, it is reported that on every C file containing the head file: ERROR C231:'D12_A0' redifinition ERROR C231:'WR_N' redifinition ERROR C231:'RD_N' redifinition No other place in the project define these three, I have searched for within but no discovery. If i rem all definitions but these three in this head file, nothing change. If i merely rem these three and left others untouch, no compiling error any more.
"The problem is that you have initialized variable definitions in a header file." Not quite!
sbit D12_A0 = P1^3; sbit MCU_INT1 = P1^4; sbit WR_N = P1^6; sbit RD_N = P1^7;
the '=' sign is not an assignment Of course not. Nor did I claim it was, or did I?. It's an initializer. And that's exactly the problem. You can never have more than one initializer for the same object in the entire project.