//------------------------------------------------------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;

上面的代码我试图实现,但MPLABXC8编译器,但不喜欢的标签(PCA21125 hߖu 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

等等。

最佳答案

看起来PCA21125_t的typedef引用了稍后在文件中定义的类型PCA21125_00H_CTRL1_t,因此它还没有在CTRL1成员声明中引用的点上定义。如果您颠倒两个typedef的顺序,它可能会编译。

10-08 13:33