You need to Cast the type for GetObjectPtr like this:-
ListPtr listP; listP =(ListPtr) GetObjectPtr (form, PATsList)
Chris.
Andre Augusto wrote:
Hello, and thanks for the Tip!!! By the way, usually this errors appear to me because I have some examples written in C, but I compile to C++, because of some libraries that I must use in my application.
In some cases, I have also an error with he function "GetObjectPtr". For example, the next part of code is created with codewarrior:
/********************************************************************* * Helper template functions *********************************************************************/ /* use this template like: * ControlType *button; GetObjectPtr(button, MainOKButton); */ template <class T> void GetObjectPtr(typename T * &ptr, UInt16 id) { FormType * form; form = FrmGetActiveForm(); ptr = static_cast<T *>( FrmGetObjectPtr(form, FrmGetObjectIndex(form, id))); }
/* use this template like: * ControlType *button = * GetObjectPtr<ControlType>(MainOKButton); */ template <class T> typename T * GetObjectPtr(UInt16 id) { FormType * form; form = FrmGetActiveForm(); return static_cast<T *>( FrmGetObjectPtr(form, FrmGetObjectIndex(form, id))); }
But when I use something like...
FormType * form = FrmGetActiveForm(); ListPtr listP; listP = GetObjectPtr (form, PATsList);
...the compiler gives me an error saying "illegal use of type void". What can I do to solve this problem once and for all?
Thanks a lot! Andr� Augusto
Juergen Wind wrote:
Tim Kostka wrote:
Change it to:
theList [i] = (char*) MemPtrNew (1);
This just explicitly typecasts the void* pointer into a char* pointer, which is what you want.
.. or even better, do it the C++ way :
theList[i] = static_cast<char*>(MemPtrNew(1));
J�rgen
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
