Try...
(char*) s = CtlGetLabel(GetObjectPtr(ReadyButton));
... that might get rid of your error message, but might not solve the problem that you are asking about.
Bob.
Curtis wrote:
Chris Tutty wrote:
Often this is a sign of memory corruption, unitialised
pointers, use of freed memory, etc.
Thanks for the inputs. I've checked over my code, and I use pointers minimally. I normally declare strings as arrays (with dimensions), not just pointers, but there is one case that I'm unsure of. I have a string pointer declared as "char *s", then use it like this:
s = CtlGetLabel(GetObjectPtr(ReadyButton));
This has always given me a warning "assignment discards qualifiers from pointer target type", which I've simply ignored, and thought I was getting away with it. The prototype for the CtlGetLabel() API is given as
const Char *CtlGetLabel(const ControlType *controlP)
so I've assumed that it was complaining that my string s wasn't declared as "const". Is this right? The reason that I suspect this is because when single-stepping through my program with the debugger (and POSE), when my assignment statement is executed, a variable completely separate from s takes on a different value. The string pointed to by s does still have the value that I'm looking for, but it's really concerning to have it alter the value in a memory location completely removed from there. Is there another way to capture the label on a button?
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
