Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!apple!sun-barr!decwrl!hplabs!hp-ses!hpcuhb!hpcllla!hpclisp!hpclscu!shankar From: shankar@hpclscu.HP.COM (Shankar Unni) Newsgroups: comp.lang.c++ Subject: Re: "//" comments and #define's : problems Message-ID: <1000021@hpclscu.HP.COM> Date: 24 Jul 89 20:20:17 GMT References: <1000019@hpclscu.HP.COM> Organization: Hewlett-Packard Calif. Language Lab Lines: 40 > What about: > (d) Insert the carriage return which terminates the comment as well, > as in > x b // comment > y I'm uncomfortable about this, for a couple of reasons: (a) You're overloading the Newline. If you suck up the newline as part of the comment, then the #define mechanism should not see the newline. Consider, for example, #define foo bar /* */ You surely wouldn't treat the embedded newline as a #define terminator. In your example, if you treat the newline as part of the comment, then you've got the same thing - a newline embedded in a comment, devoid of its special properties with respect to #define's. Strictly speaking, the preprocessor should then continue on to the next line and tack on those tokens onto the expansion list. (b) Consider, also, tokenizing preprocessors (not the character-based ones like the classic /lib/cpp). These preprocessors would convert input into discrete tokens (and would convert newlines into a unique, white-space-like token so that the #define mechanism would see it separately from other whitespace). If you asked such a preprocessor to suck up the newline as part of the "comment" token, it would "lose" the newline (after all, the same character cannot be a part of two different tokens). In fact, the approach that I ended up taking is to strip out "//" comments from #defines entirely. They will not show up even if "-C" is requested. It's a minor aesthetic wart, but semantically it's much more satisfying.. ----- Shankar Unni E-Mail: Hewlett-Packard California Language Lab. Internet: shankar@hpda.hp.com Phone : (408) 447-5797 UUCP: ...!hplabs!hpda!shankar