SourceForge has been redesigned. Learn more.
Close

Weird Syntax Error

Kevin Cox
2012-01-17
2013-03-12
  • Kevin Cox

    Kevin Cox - 2012-01-17

    I am compiling a simple program and am getting a weird sounding error.  I am new to sdcc but quite seasoned in C.

    #define __16f690
    #include <pic16f690.h>
    #include <stdint.h>
    void main ( void )
    {
        TRISB = 0xFF;
        unsigned char c = 1;
    }
    

    Gives:

    $ sdcc -mpic14 -p16f690 --use-non-free main.c
    main.c:10: syntax error: token -> 'unsigned' ; column 9
    

    But if I comment our the first line:

    #define __16f690
    #include <pic16f690.h>
    #include <stdint.h>
    void main ( void )
    {
    //  TRISB = 0xFF;
        unsigned char c = 1;
    }
    

    I get:

    $ sdcc -mpic14 -p16f690 --use-non-free main.c
    message: using default linker script "/usr/share/gputils/lkr/16f690.lkr"
    

    I was hoping someone a bit more seasoned could help me out.

    And for refrence:

    # uname -a
    Linux kevinnet 3.1.8-1-ARCH #1 SMP PREEMPT Sat Jan 7 08:03:08 UTC 2012 i686 Intel(R) Atom(TM) CPU N455 @ 1.66GHz GenuineIntel GNU/Linux
    # sdcc --version
    SDCC : mcs51/gbz80/z80/z180/r2k/ds390/pic16/pic14/TININative/ds400/hc08 3.1.0 #7066 (Dec 27 2011) (Linux)
    
     
  • Kevin Cox

    Kevin Cox - 2012-01-17

    Oh, and I realized stdint.h wasn't needed.  I get the same error when it is removed.

    #define __16f690
    #include <pic16f690.h>
    void main ( void )
    {
        TRISB = 0xFF;
        unsigned char c = 1;
    }
    
     
  • Kevin Cox

    Kevin Cox - 2012-01-17

    The same thing happens if I replace the assignment with a function call.

    #define __16f690
    #include <pic16f690.h>
    void func ( void )
    {
        return;
    }
    void main ( void )
    {
        func();
        int c;
    }
    
     
  • Maarten Brock

    Maarten Brock - 2012-01-17

    You are not seasoned enough it seems. Placing variable declarations after instructions is only allowed in C99 and not in C89. And furthermore SDCC does not support it in any mode as described in the manual under ANSI compliance.

     
  • Kevin Cox

    Kevin Cox - 2012-01-17

    Thank you,  I thought of this as I was going to bed.  its been forever since I used c89 complaint c.  Thanks once again and have a great day.

     

Log in to post a comment.