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

about getting error as errorC129: missing ';' before '.'

Hi, I am using Keil uVision3 and have written code in C which includes three files as key.c,key.h and main.c. when I compile my code as error C129: missing ';' before '.' for the line exactly where I initialize my structure element to zero in key.c

My code is as follows:

File main.c


#include <REG51.H>
#include "key.c"

void main()
{
 key_task();

 while(1);
}

File key.h


#ifndef KEYPAD_H_INCLUDED
#define KEYPAD_H_INCLUDED

sbit ke1=P2^0;
sbit ke2=P2^1;
sbit ke3=P2^2;
sbit ke4=P2^3;


sbit ds0=P3^4;
sbit ds1=P3^5;
sbit ds2=P3^6;
sbit ds3=P3^7;


typedef struct
{
 unsigned char key_pres_cnt,key_rls_cnt,key_pres_flg,key_rls_flg,key_type,ket_status;
}key;

extern key k1,k2,k3,k4;


enum key_stat{no_key_pres,key_pres};


void key_task();



#endif /*KEYPAD_H_INCLUDED*/


File key.c


#include <REG51.H>
#include "key.h"


key k1,k2,k3,k4;


k1.key_pres_cnt=0;
k1.key_pres_flg=0;
k1.key_rls_cnt=0;
k1.key_rls_flg=0;



void key_task()
{
 //Logic for first key


 if(ke1==no_key_pres)
{
 if(k1.key_pres_cnt<10)

 k1.key_pres_cnt++;


 else
 {
  if(k1.key_pres_cnt)

  k1.key_pres_cnt--;

 }

 if(k1.key_pres_cnt>=10)
 {
  k1.key_pres_cnt=0;

  k1.key_pres_flg=1;
 }

 if(k1.key_pres_flg==1)

 ds0=0;


 if(ke1==key_pres)
 {
  if(k1.key_rls_cnt<10)

  k1.key_rls_cnt++;


  else
  {
   if(k1.key_rls_cnt)

   k1.key_rls_cnt--;

  }

  if(k1.key_rls_cnt>=10)
  {
   k1.key_rls_cnt=0;

   k1.key_rls_flg=1;

   k1.key_pres_flg=0;
  }

  if(k1.key_rls_flg==1)

  ds0=1;

 }
}
}



Please help me

Thanks in advance

Parents
  • So you didn't spend time and read the information I linked to?

    The ":" form was specifically described in that link to be an old gcc extension. And I said you should stay away from any gcc extensions you might have seen.

    And the "." form is C99 - which requires that the compiler supports the C99 language standard, and that you have enabled C99.

    Note that you - for some very strange reason - have selected "Toolset = None" instead of selecting C51 which the used header file seems to indicate that you are using.

    http://www.keil.com/support/docs/1893.htm

    See specifically

    Information in this article applies to: [...] C51 All Versions
    

    and the note

    Keil C compilers are based on C90. We added some language extensions as practical
    concessions to the architectural peculiarities of the microcontrollers we support and the
    needs of embedded systems programmers.
    

    So unless Keil has failed to keep that linked document up to date, you don't get C99 support with the C51 compiler.

Reply
  • So you didn't spend time and read the information I linked to?

    The ":" form was specifically described in that link to be an old gcc extension. And I said you should stay away from any gcc extensions you might have seen.

    And the "." form is C99 - which requires that the compiler supports the C99 language standard, and that you have enabled C99.

    Note that you - for some very strange reason - have selected "Toolset = None" instead of selecting C51 which the used header file seems to indicate that you are using.

    http://www.keil.com/support/docs/1893.htm

    See specifically

    Information in this article applies to: [...] C51 All Versions
    

    and the note

    Keil C compilers are based on C90. We added some language extensions as practical
    concessions to the architectural peculiarities of the microcontrollers we support and the
    needs of embedded systems programmers.
    

    So unless Keil has failed to keep that linked document up to date, you don't get C99 support with the C51 compiler.

Children