Article View: comp.std.c
Article #3881Re: Can somebody explain how or when I can use "#if 0"?
From: Tanmoy Bhattacharya
Date: Mon, 28 Aug 1995 14:29
Date: Mon, 28 Aug 1995 14:29
50 lines
3053 bytes
3053 bytes
In article <41si6s$4qs@lyra.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk (Nick Maclaren) writes: <snip> |> This is the usual reason, but be warned that SOME compilers will parse The SOME above refers to every ANSI compliant compiler. The preprocessor works after the text has been `tokenized' (Actually, pp-token-ized), and hence invalid tokenization (incomplete character or string constants or incomplete comments) can lead to problems. In addition, the skipping is not `total': preprocessing directive _names_ are processed (though not the rest of them: except that they are pp-tokenized of course), and so invalidly names preproprecessing directives can cause problems. |> (or partially parse) some of the excluded text. You should therefore |> not use this trick to exclude syntactically invalid C. The reason for It can be syntactically invalid C: it must not be _lexically_ invalid C. Thus, you can skip over `The quick brown fox.' even if you have defined no macros (and then it is clear that it cannot be `syntactically' valid C code), and yet you cannot skip over `My father's house' because the unmatched single quote leads to problems with parsing the text lexically. |> this problem is that the standard is unclear in this area. Why do you claim the _standard_ is unclear in this area? Which standard are you talking about? There does not seem to be any hint of lack of clarity in the ANSI standard! |> |> >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. |> |> There is one case where they SHOULD appear in finished code: that is |> where the code is left as an example, and cannot be used without further |> editing. I use '#if 0 == 1' AND comment the code in such cases. To each his own. I prefer `#if 0' over `#if 0 == 1'. But if someone wanted to write `#if (0 == 1) != (0 == 1)', or followed some other `higher principle' by needless obfuscation and/or verbosity, I wouldn't complain either. Cheers Tanmoy -- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242) Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87544-0285,USA H:#3,802,9 St,NM87545 Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>, <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/ internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html> fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<41sjrp$8kb@newshost.lanl.gov>Path:
arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoyReferences:
<41rm39$o1m@ixnews5.ix.netcom.com> <41rqbi$i3o@zonker.cs.ucsb.edu> <41si6s$4qs@lyra.csx.cam.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) Newsgroups: comp.std.c Subject: Re: Can somebody explain how or when I can use "#if 0"? Date: 28 Aug 1995 14:29:13 GMT Organization: Los Alamos National Laboratory Distribution: world Message-ID: <41sjrp$8kb@newshost.lanl.gov> References: <41rm39$o1m@ixnews5.ix.netcom.com> <41rqbi$i3o@zonker.cs.ucsb.edu> <41si6s$4qs@lyra.csx.cam.ac.uk> NNTP-Posting-Host: qcd.lanl.gov