Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!rodan!rodan.acs.syr.edu!dinapoli From: dinapoli@rodan.acs.syr.edu (Ron DiNapoli) Newsgroups: comp.sys.mac.programmer Subject: MPW 2.0 and 3.0/3.1 Message-ID: <3238@rodan.acs.syr.edu> Date: 9 May 90 15:16:32 GMT Sender: dinapoli@rodan.acs.syr.edu Reply-To: dinapoli@rodan.acs.syr.edu (Ron DiNapoli) Distribution: usa Organization: Syracuse University, Syracuse, NY Lines: 57 A few weeks back I posted a message regarding a problem I was having with the MPW 3.0 C pre-processor. This problem reared its ugly head when I at- tempted to port my MPW 2.0 C code to 3.0. The majority of responses I re- ceived 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: #define PRINTIT(prstr) printf("PRINTIT has been called with: %s\n",prstr); and the following program: main() { PRINTIT("/* This is a comment */") PRINTIT(" This is normal text ") PRINTIT(" // Another type of comment") } The preprocessor (3.1 C) will output the following: main() { printf("PRINTIT has been called with: %s\n",""); printf("PRINTIT has been called with: %s\n"," This is normal text "); Obviously, it was unable to finish expanding the last macro because of the // comment character. Attempting to further compile this example will NOT work! 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! Ron D.