Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site ada-uts Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!ima!inmet!ada-uts!richw From: richw@ada-uts Newsgroups: net.lang.c Subject: Re: #define kinda stuff Message-ID: <10200041@ada-uts> Date: Tue, 15-Apr-86 09:24:00 EST Article-I.D.: ada-uts.10200041 Posted: Tue Apr 15 09:24:00 1986 Date-Received: Thu, 17-Apr-86 05:38:03 EST References: <1458@cwruecmp.UUCP> Lines: 41 Nf-ID: #R:cwruecmp.UUCP:1458:ada-uts:10200041:000:1849 Nf-From: ada-uts!richw Apr 15 09:24:00 1986 I don't have any suggestions, but I might be able to provide some insight... I think it depends on your implentation of C. You see, it depends on what the "lexical analyzer" of your particular compiler does to the text in the C-preprocessor lines. It would seem that when you say: #define foo that this has the same effect as doing a global replace, as editors do, of "foo" with "". However, at least some compilers I know of first cut up "" into lexical tokens, i.e. it breaks up the text into identifiers, strings, special C symbols (like '{' and '}'), and so on. This sequence of TOKENS, (not simply the sequence of characters) is then used wherever "foo" is encountered (this is actually more efficient since lexical analysis of "" is then only performed once for each occurence of "foo"). The important point, though, is that most lexical analyzers throw away comments. So, if your compiler does this, I see little hope of EVER being able to re-define C's comment delimiters. Judging by your description of the various things you tried, it seems as if your compiler does indeed lex the text of a define, so if I were you I'd give up and REALLY start hacking with "sed" or something. By the way, you'd think that what C is supposed to do here is well- defined. Well, unless the standard that ANSI's working on does so, I know of no such clear definition. A while ago, I played with the idea of writing a lexer for C and discovered that there were some ambiguities (within Kernighan & Ritchie, at least) as to what #define REALLY means. You might want to check Harbison & Steele; that C text might make mention of this sort of thing (I, unfortunately, don't own a copy, but I've looked at it and it's usually more specific than K&R about most things). Hope this helped, Rich Wagner