What is BOOL datatype in C99

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AmberJain
    Recognized Expert Contributor
    • Jan 2008
    • 922

    What is BOOL datatype in C99

    What is BOOL datatype in ANSI C99? I expect it to be related with BOOLEAN.
    I searched internet for it but ended with information of no use.
    Looking for an detailed description of BOOL........... .....


    _______________ _______________ _______________ _______________ _____
    Is there any ANSI C99 based compiler for download from internet?


    THANKS.........
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Let me know what you find out. I thought BOOL was a Microsoft typedef of an unsigned int. You were you test it a TRUE or FALSE since it could contain numbers other than 0 or 1.

    FALSE is:

    #define FALSE 0

    and TRUE is:

    #define TRUE !FALSE

    Comment

    • AmberJain
      Recognized Expert Contributor
      • Jan 2008
      • 922

      #3
      Originally posted by weaknessforcats
      Let me know what you find out. I thought BOOL was a Microsoft typedef of an unsigned int. You were you test it a TRUE or FALSE since it could contain numbers other than 0 or 1.

      FALSE is:

      #define FALSE 0

      and TRUE is:

      #define TRUE !FALSE
      I'm presently referring to the book-------->

      Computer Fundamentals and Programming in C
      By : PRADIP DEY and MANAS ghosh
      OXFORD university press

      In this book, on page-205 , it is mentioned that-
      _______________ _______________ _______________ _______________ _____
      "A complete list of possible data types is as:

      bool (according to C99)
      char
      unsigned char
      signed char
      int
      unsigned int
      signed int
      short int
      unsigned short int
      signed short int
      long int
      signed long int
      unsigned long int
      float
      double
      long double
      _______________ _______________ _______________ _______________ _____

      I couldnot find (probably) anything else about it in that book as it is based on ANSI C89 (probably).
      That's it. All that I know about BOOL presently is this. Any help in this matter is welcomed....... ......

      ~~THANKS~~

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        There is a difference between BOOL and bool. I mean, a visual difference.

        In C++ bool is a type that contains true or false:
        [code=cpp]
        bool var = true;

        if (var == false)
        {
        etc....
        [/code]

        Comment

        • AmberJain
          Recognized Expert Contributor
          • Jan 2008
          • 922

          #5
          Originally posted by weaknessforcats
          There is a difference between BOOL and bool. I mean, a visual difference.

          In C++ bool is a type that contains true or false:
          [code=cpp]
          bool var = true;

          if (var == false)
          {
          etc....
          [/code]
          _______________ _______________ _______________ _______________ _____
          That's fine........
          But I need to ask two things :
          1. Whether bool datatype works in C (not C++) or not.
          2. Whether bool datatype works fine even with ANSI C89 compilers.

          THANKS

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            bool does not exist in C89 as a datatype.

            That's why the BOOL macro exists.

            I don't know about C99. Did you try it??

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              The bool type is in the C99 standard (copied from C++) and I would hope by now most C99 compilers support it (back in 2001-2002 many supposedly C99 compilers didn't).

              Surprisingly C99 is not terribly popular, if a project is written in C as opposed to C++ then it tends to be C89 still.

              Comment

              • AmberJain
                Recognized Expert Contributor
                • Jan 2008
                • 922

                #8
                Originally posted by weaknessforcats
                bool does not exist in C89 as a datatype.

                That's why the BOOL macro exists.

                I don't know about C99. Did you try it??
                _______________ _______________ _______________ _______________ _____
                Thanks......... ............... ..
                No, I didn't tried it. I'm a student and am still learning C programming (let me tell you that I don't know still to program in C++). I'm using a C89 compiler. I just encountered it (the term "bool") in the book I mentioned above and just out of curiosity I posted this question.

                THANKS ONCE AGAIN..........

                Comment

                • AmberJain
                  Recognized Expert Contributor
                  • Jan 2008
                  • 922

                  #9
                  Originally posted by Banfa
                  The bool type is in the C99 standard (copied from C++) and I would hope by now most C99 compilers support it (back in 2001-2002 many supposedly C99 compilers didn't).

                  Surprisingly C99 is not terribly popular, if a project is written in C as opposed to C++ then it tends to be C89 still.
                  _______________ _______________ _______________ _______________ _____
                  THANKS......... ..

                  Can you tell me the name (and download site) of a C99 based compiler.

                  Comment

                  • Banfa
                    Recognized Expert Expert
                    • Feb 2006
                    • 9067

                    #10
                    Originally posted by ambrnewlearner
                    Can you tell me the name (and download site) of a C99 based compiler.
                    I believe GNU g++ is C99 compatible with the correct compiler switches although there are some gaps in its implementation.

                    Microsoft does not have particular good support for C99, you can find more information on the Wikipedia C page

                    Comment

                    • AmberJain
                      Recognized Expert Contributor
                      • Jan 2008
                      • 922

                      #11
                      Originally posted by Banfa
                      I believe GNU g++ is C99 compatible with the correct compiler switches although there are some gaps in its implementation.

                      Microsoft does not have particular good support for C99, you can find more information on the Wikipedia C page
                      THANKS......... ...........

                      Comment

                      Working...