problem with bit storage class

Help
2013-02-12
2013-03-12
  • Stuart Blood

    Stuart Blood - 2013-02-12

    I'm having a problem with the bit storage class that I don't understand.   Here's my version info:

    C:\Program Files\SDCC\bin>sdcc -version
    SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08
    3.2.0 #8008 (Jul  6 2012) (MINGW32)

    Here's some sample code that I assumed would work:

    #include <string.h>

    char str = "Hello";
    bit  flag;

    void main(void)
    {
         if (strcmp(str,"Hello") == 0)
              flag = 0;
         else
              flag = 1;

         while(1);
    }

    Here's the error that I get:

    C:\Program Files\SDCC\bin>sdcc sdcctest.c
    sdcctest.c:4: syntax error: token -> 'flag' ; column 8

    Can anybody tell me what the problem is?  Thanks.

     
  • Stuart Blood

    Stuart Blood - 2013-02-12

    OK.  If I use

    __bit  flag;

    instead of

    bit flag;

    the program compiles.  Defining flag as bool doesn't work, though.  The user guide says that (1-bit wide) bool is a supported data type.  I'm puzzled.

     
  • Maarten Brock

    Maarten Brock - 2013-02-19

    bit is a keyword that has been abandoned for a while now. It is replaced by the standard conforming __bit.

    And to use bool you should include <stdbool.h> otherwise it is unknown to the compiler. It is not a basic keyword as it is in C++.

    And while you're learning about stdbool.h let me advise you to also learn about the types in stdint.h.

     
  • Stuart Blood

    Stuart Blood - 2013-02-19

    And while you're learning about stdbool.h let me advise you to also learn about the types in stdint.h.

    Will do.  Thanks!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks