[comp.lang.c] Comment in #define's

dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) (02/05/91)

I've just had a (lint) problem. Somehow lint kept complaining about not
using a return value. It turned out that this was due to a comment in a
#define which was removed. I thought this was wrong, but now I am not so
sure anymore. The code looked like:

#define ERROR(x,v)      if (x) {/*RVALUSED*/ send_answer(v); return}

void
somefunc(a,c) {
    ERROR(a == 0, 1);                                 /* 1 */
    if (c) {/*RVALUSED*/ send_answer(2); return}      /* 2 */
    ...
}

Statement 1 gave the error, while 2 was accepted without warnings. Now I am
wondering what should happen when the source file is run through only through
the preprocessor while the comments should stay in (flags: -E -Wp,-C): is
the comment in the #define supposed to be removed or not ? What does ANSI-C
say about this ?

BTW I solved the problem by using '(void)' in the define, so I don't need
    any solutions to fix this particular problem :-)
-- 
   _ _ 
  / U |  Dolf Grunbauer  Tel: +31 55 433233 Internet dolf@idca.tds.philips.nl
 /__'<   Philips Information Systems        UUCP     ...!mcsun!philapd!dolf
88  |_\  If you are granted one wish do you know what to wish for right now ?

gwyn@smoke.brl.mil (Doug Gwyn) (02/06/91)

In article <583@ssp9.idca.tds.philips.nl> dolf@idca.tds.philips.nl (Dolf Grunbauer) writes:
>... is the comment in the #define supposed to be removed or not ?
>What does ANSI-C say about this ?

The C standard does not include constraints for "lint" or partial phases
of translation.  Certainly as part of translation by a conforming C
implementation (i.e. compiler), comments get turned into white space
very early in the phases of translation.