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. Other Discussions
  3. The Weird and The Wonderful
  4. True/False Dichotomy

True/False Dichotomy

Scheduled Pinned Locked Moved The Weird and The Wonderful
6 Posts 4 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.
  • G Offline
    G Offline
    Geoff Field
    wrote on last edited by
    #1

    Here's one I spotted in a previous life: We were working in C on protocol stacks. In every C file created by a group of contractors, we found the following statements:

    #define True 0
    #define False 1

    This was endemic throughout the code produced by this particular group of contractors. Fortunately, the product never came to be. The 2001 Tech Wreck did it in. Geoff

    Professional Geek, Amateur Stage-Levelling Gauge

    P L 2 Replies Last reply
    0
    • G Geoff Field

      Here's one I spotted in a previous life: We were working in C on protocol stacks. In every C file created by a group of contractors, we found the following statements:

      #define True 0
      #define False 1

      This was endemic throughout the code produced by this particular group of contractors. Fortunately, the product never came to be. The 2001 Tech Wreck did it in. Geoff

      Professional Geek, Amateur Stage-Levelling Gauge

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Ew. While I agree that true should be zero (there are many ways of being wrong, but only one way to be correct; it's also orthogonal with strcmp), I still wouldn't do that. What we had at one place was:

      #define true (0==0)
      #define false (!true)

      G 1 Reply Last reply
      0
      • P PIEBALDconsult

        Ew. While I agree that true should be zero (there are many ways of being wrong, but only one way to be correct; it's also orthogonal with strcmp), I still wouldn't do that. What we had at one place was:

        #define true (0==0)
        #define false (!true)

        G Offline
        G Offline
        Geoff Field
        wrote on last edited by
        #3

        I've started to favour this form:

        #define TRUE (!0)
        #define FALSE (!TRUE)

        But at least I put it in a header rather than within every single source file. In this case, it was in *.c. Can you say "maintenance nightmare"? And they claimed they were a CMM level 5 company, too.

        Professional Geek, Amateur Stage-Levelling Gauge

        modified on Wednesday, February 4, 2009 6:19 PM

        P 1 Reply Last reply
        0
        • G Geoff Field

          I've started to favour this form:

          #define TRUE (!0)
          #define FALSE (!TRUE)

          But at least I put it in a header rather than within every single source file. In this case, it was in *.c. Can you say "maintenance nightmare"? And they claimed they were a CMM level 5 company, too.

          Professional Geek, Amateur Stage-Levelling Gauge

          modified on Wednesday, February 4, 2009 6:19 PM

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          The (0==0) may be more portable, which is what they were after. I just tried (0==0) and (!0) on two compilers and both agreed that they equal 1, but that may not always be (or have been) the case.

          C 1 Reply Last reply
          0
          • P PIEBALDconsult

            The (0==0) may be more portable, which is what they were after. I just tried (0==0) and (!0) on two compilers and both agreed that they equal 1, but that may not always be (or have been) the case.

            C Offline
            C Offline
            ClementsDan
            wrote on last edited by
            #5

            Many C compilers (and ancient C++ compilers) don't support the bool type. The expression (0==0) has the advantage of having type bool when possible and int otherwise.

            1 Reply Last reply
            0
            • G Geoff Field

              Here's one I spotted in a previous life: We were working in C on protocol stacks. In every C file created by a group of contractors, we found the following statements:

              #define True 0
              #define False 1

              This was endemic throughout the code produced by this particular group of contractors. Fortunately, the product never came to be. The 2001 Tech Wreck did it in. Geoff

              Professional Geek, Amateur Stage-Levelling Gauge

              L Offline
              L Offline
              Lutoslaw
              wrote on last edited by
              #6

              I would love to have macro-definitions in C# or Java just to break all these silly stereotypes.

              #define max(a,b) (a>b ? b : a)
              #define min(a,b) (a>b ? a : b)

              or

              #define cerr (cin)
              #define cout (cerr)
              #define cin (cout)

              Aaah so confusing so sweet ... ;P

              Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

              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