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

Can anybody here explain this problem?

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.

Parents
  • By the way, I can not accept the method that that post mentioned. It will make maintanence more difficult as it was before the ifndef-def-endif appear.

    For easier maintenance you may use the following approach:

    In your C code files place a definition like

    #define SENSORS_MODULE
    before you include the required header files.
    In the according header use someting like
    #ifndef SENSORS_H
    #define SENSORS_H
    
    #ifdef _DECL
    	#undef _DECL
    #endif
    #ifdef SENSORS_MODULE
    	#define _DECL
    #else
    	#define _DECL	extern
    #endif
    
    _DECL UI16 GetVoltage();
    _DECL UI8  ui8_SomeVariable;
    
    #endif // SENSORS_H
    

    Thus you have only to maintain a single point of code.
    However I doubt that this will fix your sbit problems. Are you sure, that there is no second definition in some header file you use?

    Tim

Reply
  • By the way, I can not accept the method that that post mentioned. It will make maintanence more difficult as it was before the ifndef-def-endif appear.

    For easier maintenance you may use the following approach:

    In your C code files place a definition like

    #define SENSORS_MODULE
    before you include the required header files.
    In the according header use someting like
    #ifndef SENSORS_H
    #define SENSORS_H
    
    #ifdef _DECL
    	#undef _DECL
    #endif
    #ifdef SENSORS_MODULE
    	#define _DECL
    #else
    	#define _DECL	extern
    #endif
    
    _DECL UI16 GetVoltage();
    _DECL UI8  ui8_SomeVariable;
    
    #endif // SENSORS_H
    

    Thus you have only to maintain a single point of code.
    However I doubt that this will fix your sbit problems. Are you sure, that there is no second definition in some header file you use?

    Tim

Children
No data