#if

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • QreepyBORIS
    FFR Player
    • Feb 2003
    • 7454

    #1

    #if

    So I remember learning about a year ago that you could use #if/#if 0 to basically comment out immense portions of code, no matter what types of comments or nested comments there were in the code. This was really handy in robotics when we made some code that could have been better (we had a "Code Graveyard", complete with an Ascii grave and flowers), but I kind of forgot the syntax for it. Can anyone help? Does anyone know whether it is complier-specific or or whther it will also work in C++?

    Thanks in advance. I know the question was a little odd and a bit specific, but hey, if someone tells me the syntax again, it would be extremely handy.

    Oh, and I would just ask the people in robotics, but those who were good at programming in the club basically all left to go to universities. Arun's quite good, but I don't think he knows this, because I asked him earlier.

    Signature subject to change.

    THE ZERRRRRG.
  • ad0gg
    FFR Player
    • Dec 2003
    • 989

    #2
    RE: #if

    If you want to comment something out in C++, you can use // to comment a single line or /* and */ to comment out a large block of code (or anything else you want). I have never heard of #if/if# 0 before.

    Comment

    • lightdarkness
      Summer!!
      • Jul 2003
      • 11308

      #3
      RE: #if

      You're thinking of /*

      */

      But # is allowed in some languages as signifiying a comment.

      Comment

      • QreepyBORIS
        FFR Player
        • Feb 2003
        • 7454

        #4
        RE: #if

        Um, no, that is not what I am thinking of. I am definitely thinking of #if.

        Eh.

        Signature subject to change.

        THE ZERRRRRG.

        Comment

        • soccr743
          FFR Player
          • Dec 2003
          • 549

          #5
          RE: #if

          What you are talking about is compiler ifs. Although I personally have never used them yet, the syntax should be like this:

          #if <Statement using #defined variables only>

          exit(0);

          #endif

          If the statement is true, then the compiler compiles the code within that if... If not, then it is left out of the program.

          -----Soccr743-----

          Comment

          • QreepyBORIS
            FFR Player
            • Feb 2003
            • 7454

            #6
            RE: #if

            A-ha!

            I think the syntax for the MASSIVE coment-out is like this:

            #if 0
            //There is stuff in here.
            #endif

            I am almost certain that's how it went. Thank you, soccr. It's actually really handy when you want to just take huge blocks out of your program in no time without deleting the code.

            Signature subject to change.

            THE ZERRRRRG.

            Comment

            Working...