1
//------------------------------------------------------Experimental
typedef struct tagPCA21125_00H{ 
union  
    {                                           
    UCH8 DATA[0x0F];                                
    struct  {
                    PCA21125_00H_CTRL1_t    CTRL1;  //Byte 0
                    PCA21125_01H_CTRL2_t    CTRL2;
                    PCA21125_02H_tSec_t tSec;
                    PCA21125_03H_tMin_t tMin;   // t = time, a = alarm
                    PCA21125_04H_tHr_t  tHr;
                    PCA21125_05H_tDay_t tDay;
                    UCH8            tWeekday;
                    PCA21125_07H_tMonth_t   tMonth;
                    PCA21125_08H_tYear_t    tYear;
                    UCH8            aSec;       
                    UCH8            aMin;
                    UCH8            aHr;
                    UCH8            aWeekday;
                    PCA21125_0DH_CLKOUT_t   CLKOUT;
                    PCA21125_0EH_Timer_t    TimerCTRL;
                    UCH8            TimerData;
        };
    };
}PCA21125_t;
extern volatile PCA21125_t PCA21125;


//------------------------------------------------------Control 1
typedef struct tagPCA21125_00H{ 
union  
    {                                           
    UCH8 Byte;                      
    struct  {
                UCH8 :1;        //Bit0
                UCH8 :1;
                UCH8 h12_24:1;  // Must be 0 (alway)
                UCH8 POR_OVRD:1;                        
                UCH8 :1;                
                UCH8 STOP:1;    // Must be 0 (alway)
                UCH8 :1;                    
                UCH8 EXT_TEST:1;                        
        };
    };
}PCA21125_00H_CTRL1_t;
//extern volatile PCA21125_00H_CTRL1_t PCA21125_CTRL1;

上面的代码我试图实现,但是 MPLABX XC8 编译器,但是不喜欢标签(PCA21125_00H_CTRL1_t CTRL1),所以我做错了什么?,如何解决这个问题?

提供的编译器错误

0_Main/../5_PCA21125/PIC18_PCA21125.h:29: warning: missing basic type; int assumed
0_Main/../5_PCA21125/PIC18_PCA21125.h:29: error: ";" expected
0_Main/../5_PCA21125/PIC18_PCA21125.h:29: warning: missing basic type; int assumed
0_Main/../5_PCA21125/PIC18_PCA21125.h:30: warning: missing basic type; int assumed
0_Main/../5_PCA21125/PIC18_PCA21125.h:30: error: ";" expected
0_Main/../5_PCA21125/PIC18_PCA21125.h:30: warning: missing basic type; int assumed

等等等等

4

1 回答 1

1

看起来 typedef forPCA21125_t指的是 type PCA21125_00H_CTRL1_t,该类型稍后在文件中定义,因此在成员声明中引用它的位置尚未定义CTRL1。如果你颠倒两个 typedef 的顺序,它可能会编译。

于 2012-10-19T05:50:45.977 回答