CtlGetLabel() is defined as returning (const char *). The compiler will complain that you are assigning a (const char *) to a (char *). The 'const' keyword is the issue. The 'const' tells the compiler to treat the value as non-writeable, in this case the data the returned pointer points to. AFAIK, you can (cast) away any declaration.
const char *p = char * // okay - the compiler can accept writeable as non-writeable char *p = const char * // not okay - the compiler cannot accept non-writeable as writeable char *p = (char*) const char * // okay - you are overriding the compiler with the cast -------------------- Jeff Loucks Work 425-284-1128 [EMAIL PROTECTED] Home 253-851-8908 [EMAIL PROTECTED] Mobile 253-691-8812 -----Original Message----- From: Robert Moynihan [mailto:[EMAIL PROTECTED] Sent: Thursday, January 06, 2005 7:14 PM To: Palm Developer Forum Subject: Re: Debug app works, Release doesn't Chris Tutty wrote: >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. > > Actually, I did make a mistake. I meant to write (Char*) instead of (char*). The docs say the prototype is... const Char *CtlGetLabel(const ControlType *controlP) ... so I gave a try casting it exactly as the prototype and it eliminated the error message. I didn't know WHY it worked, so, not understanding all the mysteries of compilers, I then went on to see if I could figure out what was happening. I originally thought that Char* and char* were the same, and the ONLY thing that I changed between the 6 trials was the case of the 'c' in the declaration and cast: All 4 of these give the warning message: char *s; s=CtlGetLabel(GetObjectPointer(DBTypeTriggerID)); Char *s; s=CtlGetLabel(GetObjectPointer(DBTypeTriggerID)); char *s; (char*) s=CtlGetLabel(GetObjectPointer(DBTypeTriggerID)); Char *s; (Char*) s=CtlGetLabel(GetObjectPointer(DBTypeTriggerID)); These 2 don't: char *s; (Char*) s=CtlGetLabel(GetObjectPointer(DBTypeTriggerID)); Char *s; (char*) s=CtlGetLabel(GetObjectPointer(DBTypeTriggerID)); This all feels very odd to me. I wish I understood it better. Bob. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
