On 4/27/2010 8:18 AM, Bart Vandewoestyne wrote:
> I noticed that the following line
>
> sscanf(buf, "%*d %lf %lf %*lf", VX+n, VY+n);
>
> leads to the following gcc warning:
>
> warning: use of assignment suppression and length modifier
> together in gnu_scanf format
>
> I would assume this is due to the %*lf format specifier. To
> solve the problem, i noticed that changing the line to
>
> sscanf(buf, "%*d %lf %lf %*f", VX+n, VY+n);
>
> makes the warning go away. It appears that %*lf is something
> 'bad' to use, but why? Is my solution indeed the best way to get
> rid of this warning and make my code more C89 compliant?
The code conforms, either with or without the "l" modifier,
and does what you want: It matches and converts a floating-point
number, ignores it, and moves onward (in this case, to the end
of the format string).
However, the "l" is largely meaningless. If it were not for
the "*", the "l" would mean "the corresponding argument is a pointer
to double, so store the converted value as a double (not as a float
or as a long double)." Because of the "*", though, there *is* no
corresponding argument for the "l" to describe, and no point in
trying to describe it. You've told us you have no sister, and also
mentioned that she's blonde.
Presumably, gcc thinks it odd -- not wrong, necessarily, but
odd -- to specify so much detail about an argument that doesn't
exist. gcc generates a message to draw your attention to the
oddity, in case there really is something wrong with it -- maybe
the "*" should actually have been on a different conversion, for
example. gcc generates messages for other perfectly legal but
suspicious constructs like `if (x = y)', in a similar vein.
--
Eric Sosman
lid