Defining bit variable throws syntax error

Michael
2013-05-10
2013-05-12
  • Michael

    Michael - 2013-05-10

    Hi All,

    I'm new to programming, so forgive me any simple errors. I'm trying to define a bit variable, say:

    bit flag; //just as mentioned in the manual

    When I do so, the compiler throws "syntax error: token -> flag", although 'bit' is being highlighted like 'void' or 'if' (unlike say, 'int8_t')

    Now, I've already found that 'bit' may need to be replaced with '__bit', but even when I do so, still the same error is thrown.

    What am I doing wrong? Is there a library or other setting missing? Setup: PIC, Fedora, SDCC 3.2.0, MPLABX+SDCC Toolchain v1.02.

    Thank you in advance.

     
  • Maarten Brock

    Maarten Brock - 2013-05-11

    Hello Michael,

    '__bit' is only valid for mcs51 and ds390 targets.
    But I'm worried about your statement that 'bit flag' is mentioned in the manual, it should not be, only '__bit'. Can you tell where and in which version?

    Maarten

     
    Last edit: Maarten Brock 2013-05-11
    • Michael

      Michael - 2013-05-11

      Hi Maarten,

      thank you for your reply. Like I mentioned, I'm new to programming. '__bit' indeed is mentioned in mcs51 section - didn't noticed that.

      Any idea how I can define a single bit for PIC? I know I can define a bit field (using 'struct') but I would like to use a single bit called in a definition of a function (as a parameter):

      void myFunction (__bit singleBit)
      {
      ...
      }

      I've just tried 'bool' type (instead of 'bit') in the example above, throws the same error. Is it that single bit cannot be defined for PICs? Would using a bit defined earlier in a bit field work exactly as the one being defined as a parameter of a function?

      In regards to the manual, I've just noticed it calls SDCC 3.2.1. Date is rather old (?): 2012-10-16, version 8150, page 9 - Introduction (regards changes to bit handling ~b and !b). Unless my understanding of this example is wrong.

      Cheers!

       
  • Maarten Brock

    Maarten Brock - 2013-05-12

    I have no idea if bool is supported for pic. You should at least include <stdbool.h> to use it. Also mind that the pic16 target is considered beta and pic14 is even worse.

    Seeing that we on average do only one release a year, I don't consider a manual from 2012-10-16 that old. But the good thing is that a new release is about to come out.

     
    Last edit: Maarten Brock 2013-05-12

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

Sign up for the SourceForge newsletter:





No, thanks