Hi, Bill.

If you didn't do this already, you must specify the function as static 
since there's no way to directly specify the "this" pointer using a 
simple callback function.  The compiler is complaining about the 
function's signature because the implied "this" parameter is part of the 
signature.

In general, callback functions in C++ (when called from things like X, 
etc.) really need to have extern "C" binding to be truly portable since 
these callbacks are called as C functions and there is no requirement 
that C++ and C have the same calling conventions (registers, parameter 
passing conventions, and so forth).  I think you can get away with 
simply using static, however, with PalmOS.

With respect to the object oriented-ness of callback functions under 
PalmOS, I've found that this is often more trouble than its worth.  If I 
recall correctly, most PalmOS callback functions do not allow for a 
"user data" parameter as do other environments such as X-Windows.  This 
"user-data" parameter is handy for passing to the callback function a 
pointer-to-void that can be cast to a pointer to some class.  You can 
then wrap a class member function with a simple function (with extern 
"C" binding, of course) that takes the user data parameter and casts it 
to a pointer to the proper class and then calls the member function. 
 Without such a user data parameter, it becomes much more difficult to 
determine "this".  I've found that a nice clean procedural design in 
these cases is simpler than trying to force an object oriented solution. 
 But, that's just my opinion.

Good luck.


Bill Heidler wrote:

>A couple of weeks ago I tried to use an object class method in a call to
>TblSetLoadDataProcedure( ), and couldn't get it to work.  I got a
>compile-time error to the effect that the function signature didn't match
>TableLoadDataFuncType, and the only difference was that the class method was
>qualified by the class name (sorry, I don't have the exact error message
>handy, but can construct an example if necessary).
>
> Has anyone else run into this, or know a way around it?  I tried various
>kinds of casts, etc., to no avail.  I do not consider myself a C++ language
>"expert", but definitely believe in using OO techniques as much as possible.
>
> Thanks,
> Bill Heidler
>
>
>
>
>




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

Reply via email to