Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!ucsd!ames!amelia!eos!shelby!neon!Kermit.Stanford.EDU!philip From: philip@Kermit.Stanford.EDU (Philip Machanick) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW 2.0 and 3.0/3.1 Message-ID: <1990May9.181805.10891@Neon.Stanford.EDU> Date: 9 May 90 18:18:05 GMT References: <3238@rodan.acs.syr.edu> Sender: news@Neon.Stanford.EDU (USENET News System) Reply-To: philip@pescadero.stanford.edu Distribution: usa Organization: Computer Science Department, Stanford University Lines: 41 In article <3238@rodan.acs.syr.edu>, dinapoli@rodan.acs.syr.edu (Ron DiNapoli) writes: > ... advised me to upgrade to MPW C 3.1. I did this, but the problem > did not go away. Well I finally discovered what was going wrong... I had the > following macro defined: > > #define OP(tkdef,tkname,d1,d2) {#tkdef,tkname,d1,d2} > > and I wanted to expand the following: > > OP(TK_SSLASH,"//",ASSC_YFX,400) > > Anybody see the problem? In MPW C 3.0 and later, the '//' symbol stands > for a comment. It also seems that the preprocessor is unable to detect > that this particular comment character is occurring within a string. > Since it doesn't, the preprocessor sees the open end of a string, and never > finds the closing " (because the real one was 'commented' out) before its > internal buffer overflows. Once discovered, the fix was easy. I just > changed this particular occurrance of OP to: > > OP(TK_SSLASH,"/\/",ASSC_YFX,400) > > > So, it this a bug? In my opinion it isn't. Take for example the following > macro definition: [example deleted] > Note how in the first occurrance of the PRINTIT macro, the text between the > /* */ comment characters does not appear. This tells me that in the 3.0/3.1 > C preprocessor, comments are "taken out" regardless of where they appear. > Thus my problems with the '//' in my string seems consistent with this > philosophy. For this reason, I would say it is not a bug at all! From Kernighan and Richie (2nd edition; p. 192): " Comments do not nest, and they do not occur within string or character literals. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " ^^^^^^^^^^^^^^^^^^ I haven't checked the behaviour you reported, but if MPW C 3 behaves as you suggest it does, this IS a bug. Philip Machanick philip@pescadero.stanford.edu