Strange cc warning

Norman Diamond diamond at csl.sony.JUNET
Wed Feb 1 12:57:02 AEST 1989


In article <490 at marob.MASA.COM>, daveh at marob.MASA.COM (Dave Hammond) writes:

> ../include/dsipriv.h(88) : warning 74:
> 	non standard extension used - 'macro formals in strings'

> /* copy IN to OUT for LEN chars, enclosing OUT in dbl. quotes */
> #define REQUOTE(in, out, len) if ((in) && (out)) {	\
> 				*(out) = '"';	\
> Line 88 --------------------->	strncpy((out)+1, (in), (len));	\
> 				(out)[(len)-1] = 0;	\
> 				strcat((out), "\""); \
> 				(in) = (out); }

> Note that this is a warning, not an error.  The program compiles fine
> and the macro does as intended.  If any kind soul can clue me as to the
> problem in the above macro, I'd be for(;;) indebted.

1.  One possible guess (slim chance) is the combination of all three:
  (a)  In one of your invocations, you have a "string literal" for in;
  (b)  Your compiler implements strncpy as a macro; and
  (c)  Your compiler overzealously checks the wrong conditions for
       issuing that warning.

2.  I am really curious about line 91.  When you wrap an lvalue in
    parentheses, doesn't it become an rvalue?  How can you assign to it?
-- 
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp at relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-inventing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?



More information about the Comp.lang.c mailing list