> Consequently something like
>        int (* foo) (CharPtr p)
> wouldn't work because the compiler (CW5) would view this as a near
> (2 byte) pointer, not the needed 4 byte pointer.

Um, why do you think this?  That declaration looks perfectly usable to me.
Compiling it into a sample bears this out:

int my_foo (Char* p)
{
     return 0;
}

UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
     int (* foo) (Char* p);

     foo = my_foo;

     return 0;
}

The assignment statement compiles to "LEA *-20,a2", which is exactly what you
want.

-- Keith






Stringer <[EMAIL PROTECTED]> on 06/27/2000 08:25:03 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  Stringer <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  Pointers to functions in shared libraries



I'd like to pass a pointer to an array of pointers to functions as a
parameter to a function call to a shared library.
(hey, don't you just love working with a computer language where
this sentence makes sense!)

This would allow the functions within the shared library to call functions
back in the main program.

Shared libraries use near function addresses (2 bytes), but a far address
would be needed to call the functions in the main module.
Consequently something like
       int (* foo) (CharPtr p)
wouldn't work because the compiler (CW5) would view this as a near
(2 byte) pointer, not the needed 4 byte pointer.   There may be other
issues as well.   I tried "int (far * foo)(CharPtr p)" but the compiler
rejected it.

Is there a way of specifying pointers to functions as function parameters
from a big multi-sector program to a function in a shared library
and ensuring the pointers are all correctly sized and formated so the
calls can occur?

So far I haven't found the right section in the Knowledge Base or any
of the manuals.   I suspect it is either really simple or vitually impossible.

Roger Stringer
Marietta Systems, Inc.


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






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

Reply via email to