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. To bool or not to bool in C/C++ ?

To bool or not to bool in C/C++ ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionlearning
24 Posts 8 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.
  • V Vaclav_

    Since coders - both C and C++ -cannot AGREE which way is up, I'll continue to evaluate MOST BINARY conditions explicitly to its binary values. Problem solved. Now let's solve Mac or Windows next. Have s well day,ya'l.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #21

    Vaclav_ wrote:

    C and C++ -cannot AGREE

    :confused:

    L 1 Reply Last reply
    0
    • L Lost User

      Vaclav_ wrote:

      C and C++ -cannot AGREE

      :confused:

      L Offline
      L Offline
      leon de boer
      wrote on last edited by
      #22

      Not only does he not realize that statement is incorrect what he plans to do is also going to give bugs. He is going to test for the value of true by "== 1" :-) There is another subtlety that on compares with C/C++ any other value than 0 is true. Windows and Linux both use that extensively especially on API call returns They know a function hands back a register for a bool (not a bit) so they actively exploit it Even consider normal things you see like

      void* P = malloc(100);
      if (p)
      {
      // use p as it's valid
      }

      You can't write the true case simply ... the reality is the actual test is p != 0. The moment you get MACROS you actually have no idea what the expansions are and he will end up doing things like testing "p == 1" above ... which would be an amusing bug. It's actually amusing how many problems you can create in some crazy attempt to fix a non existent problem based on total misunderstanding :-)

      In vino veritas

      L 1 Reply Last reply
      0
      • L leon de boer

        Not only does he not realize that statement is incorrect what he plans to do is also going to give bugs. He is going to test for the value of true by "== 1" :-) There is another subtlety that on compares with C/C++ any other value than 0 is true. Windows and Linux both use that extensively especially on API call returns They know a function hands back a register for a bool (not a bit) so they actively exploit it Even consider normal things you see like

        void* P = malloc(100);
        if (p)
        {
        // use p as it's valid
        }

        You can't write the true case simply ... the reality is the actual test is p != 0. The moment you get MACROS you actually have no idea what the expansions are and he will end up doing things like testing "p == 1" above ... which would be an amusing bug. It's actually amusing how many problems you can create in some crazy attempt to fix a non existent problem based on total misunderstanding :-)

        In vino veritas

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #23

        Yes, but he doesn't like being told.

        V 1 Reply Last reply
        0
        • L Lost User

          Yes, but he doesn't like being told.

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #24

          ... with only one exception: if someone agrees with him! :^)

          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