09-15-2005, 06:58 PM | #1 |
FFR Player
|
#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. |
09-15-2005, 07:30 PM | #2 |
FFR Player
Join Date: Dec 2003
Location: At My House
Posts: 989
|
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.
__________________
|
09-15-2005, 07:59 PM | #3 |
Summer!!
|
RE: #if
You're thinking of /*
*/ But # is allowed in some languages as signifiying a comment.
__________________
|
09-15-2005, 08:15 PM | #4 |
FFR Player
|
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. |
09-15-2005, 08:58 PM | #5 |
FFR Player
|
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----- |
09-15-2005, 09:35 PM | #6 |
FFR Player
|
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. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|