Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!rochester!rit!ritcsh!gregory From: gregory@ritcsh.cs.rit.edu (Greg Conway) Newsgroups: comp.lang.c Subject: Re: Re^2: Why nested comments not allowed? Message-ID: <2385@ritcsh.cs.rit.edu> Date: 22 Feb 90 17:47:25 GMT References: <1523@wacsvax.OZ> <13706@cbnewsc.ATT.COM> <4286@jhunix.HCF.JHU.EDU> <4509@jarthur.Claremont.EDU> <4292@jhunix.HCF.JHU.EDU> <5372@ur-cc.UUCP> Reply-To: gregory@ritcsh.cs.rit.edu.UUCP (Greg Conway) Organization: Computer Science House @ RIT, Rochester, NY Lines: 31 In article <5372@ur-cc.UUCP> misu_ss@uhura.cc.rochester.edu (What`s in a name?) writes: >This leads me to a question on how compilers work... >Do #defines get worked out before comments are discarded... The 'traditional' implementation is that #defines's are done by the preprocessor and comments are handled by the scanner. Under such a case, the #define's are handled first. >#define OPEN_COMMENT "/*" >#define CLOSE_COMMENT "*/" [ text deleted ] > string = OPEN_COMMENT; > printf("s% ", string); [ further text deleted] According to K&R II, page 154, the behavior of this program is undefined. (The correct format conversion is %s). Assuming that the above is merely a typo, then the output you got appears to me to be correct. - Greg -- Gregory Conway @ Computer Science House, RIT "When I was young my father told me just bad guys die -- at that time just a little white lie. It was one of the first but it hurt me the most -- and the truth stung like tears in my eyes ... and even now it makes me cry." - Fish