Path: utzoo!attcan!uunet!husc6!cmcl2!nrl-cmf!ames!ncar!noao!asuvax!stjhmc!p6.f18.n114.z1.fidonet.org!will.summers From: will.summers@p6.f18.n114.z1.fidonet.org (will summers) Newsgroups: comp.lang.c Subject: Re: defining a comment? Message-ID: <658.2333D23A@stjhmc.fidonet.org> Date: 16 Sep 88 22:38:53 GMT Sender: ufgate@stjhmc.fidonet.org (newsout1.24) Organization: FidoNet node 1:114/18.6 - Iasd Eng Bbs, Phoenix Az Lines: 66 Len Reed writes: >Can I use the Preprocessor to define a comment? > >#define STARTCOM /* No. (you were talking about ANSI right?). To resolve ambiguities ANSI defines "translation phases" that function as-if they are separate passes over the source file. Comments get replaced by a single whitespace character in "pass" 3; preprocessing directives in "pass" 4. > #define COMMENT /* > #define CLOSE_COMMENT */ > > The pre-processor considers these two lines to be functionally equivalent > to the single line: > > #define COMMENT /* #define CLOSE_COMMENT */ Yup. > which is no different than > #define COMMENT Which is precisely what "pass" 4 sees. > COMMENT > A whole bunch of stuff > CLOSE_COMMENT Try: #define COMMENT 0 #if COMMENT A whold bunch of stuff #endif /* CLOSE_COMMENT */ One might be tempted to: #define COMMENT #if 0 #define CLOSE_COMMENT #endif But ANSI (Jan '88 draft) says 3.8.3.4 Rescanning and further replacement ... The resulting completely macro-replaced preprocessing token sequence is not processed as a preprocessing directive even if it resembles one. #if 0 may not be pleasing to your sense of aesthetics, but it is a well recognized C idiom. Use it for a while and COMMENT CLOSE_COMMENT is likely to become as alien to your eye as #if 0 is now... If you are adament: write the code as you wish and run it add a trivial pre-compile pass that maps COMMENT to #if 0 to the compile script. \/\/ill-- St. Joseph's Hospital/Medical Center - Usenet <=> FidoNet Gateway Uucp: ...{gatech,ames,rutgers}!ncar!noao!asuvax!stjhmc!18.6!will.summers