[sane-devel] Re: Question regarding compiler warnings in sane-backends/sanei

Stephen Torri storri at ameritech.net
Fri Dec 7 06:27:23 GMT 2001


On Thu, 6 Dec 2001, Henning Meier-Geinitz wrote:

> > If we are changing the value of name then it makes sense to do the
> > later. Vice versa.
> 
> What you can do, is to use copies of v->name. I've done this in the
> mustek backend to avoid similar warnings.
> 

So you just send the variable by its value to the function. This way the 
original variable is not changed. Right?

If that is the case then the following line is one that is giving 
compiler warnings in sane/sane-backends/sanei/sanei_wire.c

sanei_w_string (w, (SANE_String *) & v->name);

If read this correctly we are casting the v->name to a SANE_String. We are 
sending the reference to where v->name resides in memory and not copying 
the data.

I changed the line to read:

sanei_w_string (w, (SANE_String *) v->name);

Upon recompiling I still got the warning saying "warning: cast discards 
qualifiers from pointer target type".

Now Java is my main language programming language due to that is what I
learned to program on at university. Now I beginning to understand how 
variables are handled in C and C++. Am I understanding this correctly?

Stephen




More information about the sane-devel mailing list