+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Full Member level 5
    Points: 2,451, Level: 11

    Join Date
    Nov 2011
    Location
    india
    Posts
    285
    Helped
    2 / 2
    Points
    2,451
    Level
    11

    LCD Display program in C

    Hello
    I am using AT89c51 microcntroller and Keil compiler. when I build code I am getting error
    Code:
    #include
    #define LCDPORT P1
    #define RS P2_0
    #define RW P2_1
    #define E P2_3
    bit status=0
    #define lcd_delay 60
    void delay(unsigned int j)
    {
    unsigned int i,k;
    for(i=0;i
    
    Error Message
    compiling display.c...
    display.c(8): error C141: syntax error near 'void'
    display.c(9): error C141: syntax error near '{'
    display.c(11): error C141: syntax error near 'for'
    display.c(11): error C141: syntax error near '=', expected ')'
    display.c(11): error C129: missing ';' before '<'
    display.c - 5 Error(s), 0 Warning(s).
    why I am getting this error. how to remove error ?

    •   Alt15th May 2017, 05:57

      advertising

        
       

  2. #2
    Member level 4
    Points: 1,080, Level: 7
    Altaero's Avatar
    Join Date
    Dec 2013
    Location
    St-Petersburg, Russia
    Posts
    78
    Helped
    24 / 24
    Points
    1,080
    Level
    7

    Re: LCD Display program in C

    This type of errors occurs when you miss syntax (not putting a semicolon, putting it in the wrong place etc). So when you get this error, look for it just BEFORE the error statement, in your case before 'void'.
    At first I thought about reg51.h file, but then I saw the line among the defines:
    Code C - [expand]
    1
    
    bit status=0
    As it's a variable definition, regular c-code, it must ends with a semicolon.

    Although C allows placing #define anywhere in the code, it's a good practise to place them in the beginning, and surely not mix them with c-code. It is more readable.
    And make lcd_delay with capitalized letters, again, it's more readable.



--[[ ]]--