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

error C141: syntax error near 'stTimeStr'

hi there, i have struct with the problem.I'm writing a code for DS12887,And typedef two structures in the header file.It is normal before writing a function.
But now the error C141.
I am more confused. Ask for The help
Header file:

#include <stdio.h>
#include <absacc.h>
typedef struct
{
  ......
}stTimeStr;

typedef struct
{
  ......
}stDsStatus;

void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime);

void SetClkTime(stTimeStr* stClkTime);

void SetAlmTime(stTimeStr* stAlmTime);

void GetDSStatus(stDsStatus* stStat);


C Source file:

#include <stdio.h>
#include <absacc.h>
#include "DS12887.h"

void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime)
{
  ......
}


void SetClkTime(stTimeStr* stClkTime)
{
  ......
}

void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime)
{
   ......
}
void GetDSStatus(stDsStatus* stStat)
{
  ......
}

void GetDSStatus(stDsStatus* stStat)
{
  ......
}

Parents
  • so,i feel very strange,
    If i chang code like this,then no error:

    #include <stdio.h>
    #include <absacc.h>
    #include "../ComUnit/ComUnit.h"
    #define RDADDR XBYTE[0xfb04]
    #define WR1ADDR XBYTE[0xfb01]
    #define WR0ADDR XBYTE[0xfb00]
    /************** definitions unique to high-speed micros **************/
    //sfr CKCON = 0x8e;
    /***************************** Defines ********************************/
    #define CLK_SECS XBYTE[0xfb00]          /* time, date & alarm regs */
    #define CLK_SECS_ALM XBYTE[0xfb01]
    #define CLK_MINS XBYTE[0xfb02]
    #define CLK_MINS_ALM XBYTE[0xfb03]
    #define CLK_HRS XBYTE[0xfb04]
    #define CLK_HRS_ALM XBYTE[0xfb05]
    #define CLK_DOW XBYTE[0xfb06]                   /*Day For Week*/
    #define CLK_DOM XBYTE[0xfb07]                   /*Day For Mouth*/
    #define CLK_MON XBYTE[0xfb08]
    #define CLK_YR XBYTE[0xfb09]
    #define REGA XBYTE[0xfb0a]
    #define REGB XBYTE[0xfb0b]
    #define REGC XBYTE[0xfb0c]
    #define REGD XBYTE[0xfb0d]
    #define CLK_CENTTURY XBYTE[0xfb32]
    #define RS2 0x0f
    #define RS4 0x0e
    #define RS8 0x0d
    #define RS16 0x0c
    #define RS32 0x0b
    #define RS64 0x0a
    #define RS128 0x09
    #define RS256 0x08
    #define RS512 0x07
    #define RS1024 0x06
    #define RS2048 0x05
    #define RS4096 0x04
    #define RS8192 0x03
    #define VRT 0x80
    #define E32K 0x40
    #define DVX 0x01
    #define C887 0x02
    #define VRT_SET 0x04
    #define VRT2_SET 0x08
    #define VLDMDL 0x10
    #define CRCSEROK 0x20
    //Order Day For Week:Sun,Mon,Tue,Wed,Thu,Fri,Sat0
    typedef struct
    {
            unsigned char ucSECS;
            unsigned char ucMINS;
            unsigned char ucHRS;
            unsigned char ucWEEK;
            unsigned char ucDAY;
            unsigned char ucMON;
            unsigned char ucYR;
            unsigned char ucCENT;
    }stClockTime;
    
    typedef struct
    {
            unsigned char ucSECS;
            unsigned char ucMINS;
            unsigned char ucHRS;
    }stAlarmTime;
    
    typedef struct
    {
            unsigned char ucStatsBit;
            unsigned char ucSeletWord;
    }stDsStatus;
    
    //Initialization DS12C887
    void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime)
    {
            REGA = 0xad;
            REGB = 0xa6;
            if(stClkTime->ucSECS > 0x80)
                    return;
            else
                    SetClkTime(stClkTime);
            if(stAlmTime->ucSECS > 0x80)
                    return;
            else
                    SetAlmTime(stAlmTime);
    }
    
    
    
    //Set Clock Time
    void SetClkTime(stTimeStr* stClkTime)
    {
    }
    
    //Set Alarm Time
    void SetAlmTime(stAlarmTime* stAlmTime)
    {
    }
    
    //Get DS12C887 Status WORD & BIT/
    void GetDSStatus(stDsStatus* stStat)
    {
            byte_1 uStatus = 0x00;
            byte_1 ucTemp   = 0x00;
            ucTemp = REGA;
            ucTemp = ucTemp & 0x7f;
            stStat->ucSeletWord = ucTemp;
            ucTemp = ucTemp | ((REGB& 0x07)<<1);
            stStat->ucStatsBit = stStat->ucStatsBit | ucTemp;
            ucTemp = REGC & 0xf0;
            stStat->ucStatsBit = ucTemp;
    }
    

Reply
  • so,i feel very strange,
    If i chang code like this,then no error:

    #include <stdio.h>
    #include <absacc.h>
    #include "../ComUnit/ComUnit.h"
    #define RDADDR XBYTE[0xfb04]
    #define WR1ADDR XBYTE[0xfb01]
    #define WR0ADDR XBYTE[0xfb00]
    /************** definitions unique to high-speed micros **************/
    //sfr CKCON = 0x8e;
    /***************************** Defines ********************************/
    #define CLK_SECS XBYTE[0xfb00]          /* time, date & alarm regs */
    #define CLK_SECS_ALM XBYTE[0xfb01]
    #define CLK_MINS XBYTE[0xfb02]
    #define CLK_MINS_ALM XBYTE[0xfb03]
    #define CLK_HRS XBYTE[0xfb04]
    #define CLK_HRS_ALM XBYTE[0xfb05]
    #define CLK_DOW XBYTE[0xfb06]                   /*Day For Week*/
    #define CLK_DOM XBYTE[0xfb07]                   /*Day For Mouth*/
    #define CLK_MON XBYTE[0xfb08]
    #define CLK_YR XBYTE[0xfb09]
    #define REGA XBYTE[0xfb0a]
    #define REGB XBYTE[0xfb0b]
    #define REGC XBYTE[0xfb0c]
    #define REGD XBYTE[0xfb0d]
    #define CLK_CENTTURY XBYTE[0xfb32]
    #define RS2 0x0f
    #define RS4 0x0e
    #define RS8 0x0d
    #define RS16 0x0c
    #define RS32 0x0b
    #define RS64 0x0a
    #define RS128 0x09
    #define RS256 0x08
    #define RS512 0x07
    #define RS1024 0x06
    #define RS2048 0x05
    #define RS4096 0x04
    #define RS8192 0x03
    #define VRT 0x80
    #define E32K 0x40
    #define DVX 0x01
    #define C887 0x02
    #define VRT_SET 0x04
    #define VRT2_SET 0x08
    #define VLDMDL 0x10
    #define CRCSEROK 0x20
    //Order Day For Week:Sun,Mon,Tue,Wed,Thu,Fri,Sat0
    typedef struct
    {
            unsigned char ucSECS;
            unsigned char ucMINS;
            unsigned char ucHRS;
            unsigned char ucWEEK;
            unsigned char ucDAY;
            unsigned char ucMON;
            unsigned char ucYR;
            unsigned char ucCENT;
    }stClockTime;
    
    typedef struct
    {
            unsigned char ucSECS;
            unsigned char ucMINS;
            unsigned char ucHRS;
    }stAlarmTime;
    
    typedef struct
    {
            unsigned char ucStatsBit;
            unsigned char ucSeletWord;
    }stDsStatus;
    
    //Initialization DS12C887
    void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime)
    {
            REGA = 0xad;
            REGB = 0xa6;
            if(stClkTime->ucSECS > 0x80)
                    return;
            else
                    SetClkTime(stClkTime);
            if(stAlmTime->ucSECS > 0x80)
                    return;
            else
                    SetAlmTime(stAlmTime);
    }
    
    
    
    //Set Clock Time
    void SetClkTime(stTimeStr* stClkTime)
    {
    }
    
    //Set Alarm Time
    void SetAlmTime(stAlarmTime* stAlmTime)
    {
    }
    
    //Get DS12C887 Status WORD & BIT/
    void GetDSStatus(stDsStatus* stStat)
    {
            byte_1 uStatus = 0x00;
            byte_1 ucTemp   = 0x00;
            ucTemp = REGA;
            ucTemp = ucTemp & 0x7f;
            stStat->ucSeletWord = ucTemp;
            ucTemp = ucTemp | ((REGB& 0x07)<<1);
            stStat->ucStatsBit = stStat->ucStatsBit | ucTemp;
            ucTemp = REGC & 0xf0;
            stStat->ucStatsBit = ucTemp;
    }
    

Children