Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC and its BOOL type...

MFC and its BOOL type...

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
7 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 0 Offline
    0 Offline
    0v3rloader
    wrote on last edited by
    #1

    I have a peculiar question to ask you gurus... Being the person I am who pays attention to minor details, I was wondering if you could explain me in as much detail as you can why is it that MFC and some Win32 interface methods instead of using the standard C++ bool data-type, use BOOL (which maps to the plain old int) ? Any insights you could provide would be much apreciated. Thank you so much, David Nimrod

    M 1 Reply Last reply
    0
    • 0 0v3rloader

      I have a peculiar question to ask you gurus... Being the person I am who pays attention to minor details, I was wondering if you could explain me in as much detail as you can why is it that MFC and some Win32 interface methods instead of using the standard C++ bool data-type, use BOOL (which maps to the plain old int) ? Any insights you could provide would be much apreciated. Thank you so much, David Nimrod

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      BOOL is a type defined by the Windows headers. Since MFC and Win32 were around before bool existed in C++, they use BOOL. (Actually Win32 uses BOOL to maintain C compatibility.) --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."   -- Michael P. Butler in the Lounge

      P A 2 Replies Last reply
      0
      • M Michael Dunn

        BOOL is a type defined by the Windows headers. Since MFC and Win32 were around before bool existed in C++, they use BOOL. (Actually Win32 uses BOOL to maintain C compatibility.) --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."   -- Michael P. Butler in the Lounge

        P Offline
        P Offline
        palbano
        wrote on last edited by
        #3

        Michael Dunn wrote: (Actually Win32 uses BOOL to maintain C compatibility.) All your BOOL are all belong to C :-D

        Watch out! I'm a CPian on the edge! I have a new Gold rating and I'm not afraid to use it!

        -pete

        1 Reply Last reply
        0
        • M Michael Dunn

          BOOL is a type defined by the Windows headers. Since MFC and Win32 were around before bool existed in C++, they use BOOL. (Actually Win32 uses BOOL to maintain C compatibility.) --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."   -- Michael P. Butler in the Lounge

          A Offline
          A Offline
          Abin
          wrote on last edited by
          #4

          Yeah I was told about that before. Only thing I wonder, though, is that why they used an int not an BYTE, to represent such a type that merely needs to maintain "yes or no", but then I guess we've all used to that already.

          A T H 3 Replies Last reply
          0
          • A Abin

            Yeah I was told about that before. Only thing I wonder, though, is that why they used an int not an BYTE, to represent such a type that merely needs to maintain "yes or no", but then I guess we've all used to that already.

            A Offline
            A Offline
            Antony M Kancidrowski
            wrote on last edited by
            #5

            It probably stems back to the days when we had 8-bit integers. Ant. I'm hard, yet soft.
            I'm coloured, yet clear.
            I'm fruity and sweet.
            I'm jelly, what am I? Muse on it further, I shall return!
            - David Williams (Little Britain)

            1 Reply Last reply
            0
            • A Abin

              Yeah I was told about that before. Only thing I wonder, though, is that why they used an int not an BYTE, to represent such a type that merely needs to maintain "yes or no", but then I guess we've all used to that already.

              T Offline
              T Offline
              Tim Smith
              wrote on last edited by
              #6

              Why use a BYTE instead of an int? It has all the same problems. Tim Smith I'm going to patent thought. I have yet to see any prior art.

              1 Reply Last reply
              0
              • A Abin

                Yeah I was told about that before. Only thing I wonder, though, is that why they used an int not an BYTE, to represent such a type that merely needs to maintain "yes or no", but then I guess we've all used to that already.

                H Offline
                H Offline
                Henry miller
                wrote on last edited by
                #7

                Depending on your CPU, access to anything of less than an int may be very slow. Alpha for instance (which windows NT ran on) didn't give you easy access to a single byte, it could be done, but the code was fairly high.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups