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. BOOL vs. bool

BOOL vs. bool

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studioquestion
7 Posts 5 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.
  • R Offline
    R Offline
    Roman Nurik
    wrote on last edited by
    #1

    which one is "better"? i know bool is more standardized but BOOL is more efficient, but which one is more commonly used, furthermore, which one should i use? >>Roman<<

    F T C M 4 Replies Last reply
    0
    • R Roman Nurik

      which one is "better"? i know bool is more standardized but BOOL is more efficient, but which one is more commonly used, furthermore, which one should i use? >>Roman<<

      F Offline
      F Offline
      Felix Cho
      wrote on last edited by
      #2

      Is bool less efficient? I don't think so... I usually use bool for pure C++ logic, and BOOL for UI/Win API related stuff. I have seen a lot of people mixing them and IMHO is not a good idea in terms of readability.

      1 Reply Last reply
      0
      • R Roman Nurik

        which one is "better"? i know bool is more standardized but BOOL is more efficient, but which one is more commonly used, furthermore, which one should i use? >>Roman<<

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

        BOOL edges out bool in performance just by a very tiny amount. Here are the rules I use. If I am doing WIN32 code, I use BOOL. Otherwise, for the other 90% of my code, I use bool. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

        R 1 Reply Last reply
        0
        • C Carlos Antollini

          You answered your question. I think that is better to use the more efficient... Do you prefer to use while(true) or for(;;)?:-D Regards!!! Carlos Antollini. Sonork ID 100.10529 cantollini

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

          while(true) and for(...) take the same amount of time. I have yet to see a compiler not optimize while (true) away. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

          1 Reply Last reply
          0
          • T Tim Smith

            BOOL edges out bool in performance just by a very tiny amount. Here are the rules I use. If I am doing WIN32 code, I use BOOL. Otherwise, for the other 90% of my code, I use bool. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

            R Offline
            R Offline
            Roman Nurik
            wrote on last edited by
            #5

            thanks, so for libraries i make, ill use bool if they're not windows-specific ;D >>Roman<<

            1 Reply Last reply
            0
            • R Roman Nurik

              which one is "better"? i know bool is more standardized but BOOL is more efficient, but which one is more commonly used, furthermore, which one should i use? >>Roman<<

              C Offline
              C Offline
              Carlos Antollini
              wrote on last edited by
              #6

              You answered your question. I think that is better to use the more efficient... Do you prefer to use while(true) or for(;;)?:-D Regards!!! Carlos Antollini. Sonork ID 100.10529 cantollini

              T 1 Reply Last reply
              0
              • R Roman Nurik

                which one is "better"? i know bool is more standardized but BOOL is more efficient, but which one is more commonly used, furthermore, which one should i use? >>Roman<<

                M Offline
                M Offline
                Mukkie
                wrote on last edited by
                #7

                Hi! Try this: bool test_a = 3; BOOL test_b = 3; or that one: bool test_a = true; switch(test_b) { case 4: break; case 5: break; } and the same for BOOL. You will see the difference :) Moreover: sizeof(BOOL) != sizeof(bool) ===> 4 != 1 I use always bool's, but when I deal with Win32 - I use BOOL's. Mukkie

                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