On Jul 14, 2011, at 11:00 AM, Ed Beroset wrote:
> The error messages say:
> packet-myudp.c(90) : error C2220: warning treated as error - no 'object' file
> generated
What the errors mean:
> packet-myudp.c(90) : warning C4554: '<<' : check operator precedence for
> possible error; use parentheses to clarify precedence
The expression is valid, but it might not do what you think it does. The rules
for C operator precedence (they're the same in C++) are:
http://www.difranco.net/cop2220/op-prec.htm
and those are the rules the C compiler will follow. If that means that code
isn't doing what you want, add parentheses to tell the compiler what you want.
> packet-myudp.c(782) : warning C4113: 'void (__cdecl *)()' differs in
> parameter lists from 'void (__cdecl *)(void)'
In C, a function declaration such as
void func();
means "a function that can be passed an arbitrary list of arguments", not "a
function that takes no arguments", and the same applies to function
definitions. This is for historical reasons, as C originally didn't include a
declaration of the function argument list in function definitions or
declarations; use
void func(void);
instead.
> packet-myudp.c(1119) : warning C4244: '=' : conversion from 'double' to
> 'gfloat', possible loss of data
> packet-myudp.c(1219) : warning C4244: '=' : conversion from 'double' to
> 'gfloat', possible loss of data
> packet-myudp.c(1860) : warning C4244: '=' : conversion from 'double' to
> 'gfloat', possible loss of data
Unless you really only care about single precision, you should probably use
gdouble rather than gfloat. (If you really do want to throw out about half the
precision bits, explicitly cast the "double"-valued expression to gfloat.)
> packet-myudp.c(2134) : warning C4244: '=' : conversion from 'guint16' to
> 'guint8', possible loss of data
Unless the guint16 is guaranteed to have its upper 8 bits zero, you probably
want to use a guint16 rather than a guint8.
> The difference in the makefiles is that you don't have the "warnings treated
> as error" turned on in the modified file, but that's not the correct
> modification to make. The correct way to address this is to fix the warnings
> in packet-myudp.c as pointed out by the compiler. They look like mostly
> minor things that would only need a few minutes to address and your code will
> be better quality as a result even though it may work as intended already.
Exactly.
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <[email protected]>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:[email protected]?subject=unsubscribe