Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!caip!seismo!rochester!rocksanne!sunybcs!ellie!colonel From: colonel@ellie.UUCP (Col. G. L. Sicherman) Newsgroups: net.lang.c Subject: Re: define end of comment Message-ID: <993@ellie.UUCP> Date: Tue, 22-Apr-86 15:52:50 EST Article-I.D.: ellie.993 Posted: Tue Apr 22 15:52:50 1986 Date-Received: Sat, 26-Apr-86 06:31:47 EST References: <2604@brl-smoke.ARPA> Organization: North American Veeblefetzer Lines: 52 Summary: counterexample to end-comment conjecture > When in a comment, no expansion is done! > > How do we then define something which is to end a comment? I would say > it is impossible, but is eager to hear of anybody who thinks otherwise. You can do it with bsd4.3 cc. Here's a program before preprocessing: #define SLASH / #define STAR * #define CSTART /STAR #define ALT_CSTART SLASH* #define CEND STAR/ main() { /* * Demonstrate how the Preprocessor handles comments. */ /* * It knows that this is a comment, so the next line is not expanded: CEND printf("Roses are red.\n"); */ CSTART * It does not know that this is a comment, * so it expands the end-comment token: CEND printf("Lemons are blue.\n"); ALT_CSTART * But it recognizes this as a comment! The end-marker is ignored: CEND printf("Lobsters are yellow.\n"); /* */ And here's the output from cpp, with extraneous blank lines deleted: # 1 "" main() { /* * It does not know that this is a comment, * so it interprets the end-comment token: */ printf("Lemons are blue.\n"); } My entry in the '85 Obfuscated C contest relied on this barfufeature. -- Col. G. L. Sicherman UU: ...{rocksvax|decvax}!sunybcs!colonel CS: colonel@buffalo-cs BI: csdsicher@sunyabva