Menu

syntax error: token -> '/' ; column 1

Mian Qi
2024-02-12
2024-02-12
  • Mian Qi

    Mian Qi - 2024-02-12

    I wrote "display.h" this way:

    #ifndef __DISPLAY_H_
    #define __DISPLAY_H_
    
    const  unsigned int display_segment[10] ={
    0x3f,
    0x06,
    0x5d,
    0x4f,
    0x65,
    0xd5,
    0x7d,
    0x07,
    0x7f,
    0x4f
    }
    
    const unsigned int display_digit[0]={
    0x01,
    0x02,
    0x03,
    0x04,
    0x05,
    0x06,
    0x07
    }
    
    void segmentDisplay(unsigned int segment){};
    void digitDisplay(unsigned int digit){};
    void numberDisplay(unsigned int* segment, unsigned int digit){};
    
    __sfr __at(0x80) P0;
    __sfr __at(0xA0) P2;
    __sbit __at(0xA0+2) P2.2
    __sbit __at(0xA0+3) P2.3
    __sbit__at(0xA0+4) P2.4
    
    #endif
    

    and, "display.c" this way:

    #define"display.h"
    
    void segmentDisplay(unsigned int segment)
    {
            P0 = display_segment[segment];
    }
    
    void digitDisplay(unsigned int digit)
    {
        P2 = display_digit[digit];
    }
    
    void numberDisplay(unsigned int* segment, unsigned int digit)
    {
        display_segment(*segment);
        display_digit(digit);
    }
    

    after "sdcc -c -mmcs51 --std-sdcc89 display.c", it prompted:

    display.h:5: warning 190: ISO C forbids an empty source file
    display.h:5: syntax error: token -> '/' ; column 1

    what's wrong with it?

     

    Last edit: Mian Qi 2024-02-12
  • Mian Qi

    Mian Qi - 2024-02-12

    Problem solved by following changes:
    1. add ";" at the end of array definition.
    2. there should not be "{}" at the end of function declaration.
    3. "P2.2" should be "P2_2".
    4. "sdcc -c -mmcs51 --std-sdcc89 display.c" should be "sdcc -c -mmcs51 display.c".

     

    Last edit: Mian Qi 2024-02-12

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.