🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3878

Re: Can somebody explain how or when I can use "#if 0"?

#3878
From: Steve E. Chapel
Date: Mon, 28 Aug 1995 07:13
30 lines
1488 bytes
kanghoon@ix.netcom.com (Kang H. Lee ) writes:

>Hi!

>I was looking at some code, and found this preprocessor:

>#if 0
>    ....
>#else
>    ....
>#endif

>Can somebody explain to me clearly how this works? 

I use this sometimes when I'm trying out two different pieces of code
and want to be able to switch between them quickly. If I change the
0 to a 1, the first section rather than the second section is used.

More often than that trick, I use just #if 0 ... #endif to temporarily
remove one section of code. It's safer than commenting out, because
if there are any comments inside the section, commenting out the
section won't work.

By the way, these constructs should normally not appear in finished code.
I use them (I hope) exclusively in code that I'm currently writing or
changing. I take them out when I'm done.
-- 
Steve Chapel        schapel@cs.ucsb.edu   |   http://www.cs.ucsb.edu/~schapel
   Senior in Computer Science at the      |   finger -l schapel@eci1.ucsb.edu
University of California, Santa Barbara   |        PGP key on the way...
Technical Details
Message-ID: <41rqbi$i3o@zonker.cs.ucsb.edu>
Path: arc1-ca.pugleaf.net!nntp.ucsb.edu!not-for-mail
References: <41rm39$o1m@ixnews5.ix.netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp.ucsb.edu!not-for-mail
From: schapel@zonker.cs.ucsb.edu (Steve E. Chapel)
Newsgroups: comp.std.c
Subject: Re: Can somebody explain how or when I can use "#if 0"?
Date: 28 Aug 1995 00:13:54 -0700
Organization: University of California, Santa Barbara
Message-ID: <41rqbi$i3o@zonker.cs.ucsb.edu>
References: <41rm39$o1m@ixnews5.ix.netcom.com>
NNTP-Posting-Host: zonker.cs.ucsb.edu