Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site ihlpg.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!qantel!ihnp4!ihlpg!tainter From: tainter@ihlpg.UUCP (Tainter) Newsgroups: net.lang.c Subject: Re: define kinda stuff Message-ID: <1818@ihlpg.UUCP> Date: Wed, 16-Apr-86 17:46:30 EST Article-I.D.: ihlpg.1818 Posted: Wed Apr 16 17:46:30 1986 Date-Received: Sat, 19-Apr-86 13:00:55 EST References: <2602@brl-smoke.ARPA> Organization: AT&T Bell Laboratories Lines: 31 > David Eppstein (eppstein@cs.columbia.edu, seismo!columbia!cs!eppstein) > writes (11 Apr 86 21:12:26 GMT) > > Obviously the right way to do this is the following: > > > > #define cat(a,b) a/**/b > > #define (-: cat(/,*) > > #define :-) cat(*,/) > The problem is to define '(-:' as '/*' (start of comment), and :-) '*/'. > Please correct me, but I feel this will not work. Either the cat-definition > will look like 'ab' when it is expanded - obviously wrong -, or it will > look like 'a/**/b', which is wrong also. If you get '//**/*' as the > expansion, this surely isn't a start of a comment. > The whole thing boils down to whether the preprocessor does recursive > deletion of comments, which it never has as far as I know. For example: > > /* if (variable != 21) { /* Test for ... */ > has always been a comment-line, where the first '/*' is an easy > way to discard the whole line. If you put another '*/' at the end of > the line, the 'syntax error' is very near... Ignoring the unportability of a preprocessor which accepts macros that are not identifiers. The assumption the above works on is that BOTH the preprocessor and the compiler extract comments. This is a VALID assumption which is very often violated in the name of efficiency. The compiler SHOULD strip comments even if the preprocessor does since you should not assume it will be preprocessed by a comment stripping preprocessor. But, SHOULD and does are different words. --j.a.tainter