Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!mit-eddie!genrad!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: quotes inside #if 0 Keywords: ANSI, comments Message-ID: <14512@haddock.ima.isc.com> Date: 4 Sep 89 19:43:10 GMT References: <2014@munnari.oz.au> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 29 In article <2014@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes: > #if 0 ... [English text and C examples] ... #endif >The compiler sees words like "don't" in the English text and snarls that >these are unterminated character constants. This used to be perfectly >good C... No, what you really mean is that you used to use a compiler that happened not to complain about that, and now you use one that does. The introduction of ANSI C between the two events is largely coincidental. It never was good C. Generally, if you want to hide English text from the compiler, you should use /*...*/, whereas if you want to hide C code, you should use #if...#endif. I infer from your posting that this particular instance is English text that happens to include C code within the running text, i.e. this C code is meant to be read by humans rather than being a piece of former code that's been inactivated. Probably your best bet is to move the comments into the English text, omitting the comment delimiters. >Is there a way of having mixed English text and C fragments (possibly >including C comment delimiters) in a C program which _will_ work in ANSI C? Alas, there is no perfect commenting convention; unless it's all done with an awkward prefix like a Hollerith constant, there's always something that cannot appear literally in a comment. In C it's the string "*/", and I'm afraid you'll have to live with it, or find a new language. (C++ comes to mind. It has remainder-of-line comments, which are okay if you don't mind putting the prefix on each line.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint