* Marko Pavlin <mp@...>:
> > How can I call function where address is in
> > pointer? Something like this:
> >
> > void test1(void){
> > puts("blah");
> > }
> >
> >
> > void *exec;
> >
> > void main(void) {
> > exec = (void *)test1;
> > __asm
> > {
> > BL exec
> > }
You need to declare exec as a function pointer.
Then you can assign it the address of any function
with the same prototype and call it like any other
function:
void test1(void){
puts("blah");
}
void (*exec)(void); // Declare as function pointer.
void main(void) {
exec = test1;
exec();
}
* Jim Parziale <nuncio.bitis@...>:
> After setting:
> exec = (void *)test1;
> Just call via exec:
> exec();
>
exec must be declared as a function pointer,
otherwise the compiler won't know how to set up
the parameters and pick up the return value for
the function (even if there are none in this
case.)
--
JRMessage
Re: [lpc2000] Jump from variable -> define variable as function
2006-02-23 by Jean-Rene David
Attachments
- No local attachments were found for this message.