From: "Roger Stringer" <[EMAIL PROTECTED]>
> >From: "Chris Tutty" <[EMAIL PROTECTED]>
> >From: "Robert Moynihan" <[EMAIL PROTECTED]>
> > > (char*) s = CtlGetLabel(GetObjectPtr(ReadyButton));
> > >
> > > ... that might get rid of your error message, but might not solve the
> > > problem that you are asking about.
> > >
> >How on earth is this going to make any difference?  Aside from
> >the questionable approach of trying to eliminate a warning rather
> >than fix the underlying problem, how would casting a variable
> >defined as char * to char * change anything.
> 
> When you are dealing with a weird problem, the first step is to go 
> through the program and resolve all the compiler warnings.  This 
> is not a questionable approach, but a desirable first step.
> 
I'm surprised to hear an experienced programmer support advice
to "get rid of" a warning rather than solve the problem causing it.

I think your statement "resolve all the compiler warnings" is 
the same advice as mine to "fix the underlying problem", but 
the important difference rests on the interpretation of 'resolve', 
which some programmers interpret as 'make it go away 
somehow', and certainly that was the suggestion that I 
originally complained about.  Robert's second suggestion to
declare the variable as const so that the cast is unnecessary is 
a much better suggestion, since it should also reveal whether 
the variable is being assigned to elswhere in the code, which
might be a problem.

We're getting off the subject of the problem into a discussion of
development methodology, but since I've dealt with a 
lot of early C programmers who make the mistake of thinking
that when the warning is gone the problem is fixed I'd like to
repeat my contention that fixing the problem is far more likely
to result in robust, reliable code than just adding casts until
the warning goes away.  Casts can often remove a warning
but leave the original problem in place causing difficult
debgging exercises downstream.

My advice to any C programmer is to avoid casting a warning 
until you understand exactly why it's happening and then, and 
only then, adjust the code so that it doesn't appear using casts
only as a last, and well-documented, resort.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to