AXDRW%ALASKA.BITNET@cunyvm.cuny.edu (Don R. Withey) (05/02/89)
How does one prototype a function pointer in Lattice 5.02? I have a function
pointer that I want to force Lattice to pass the arguments in certain
registers. For example:
extern __far __asm MyFunc(register __a0 struct Window *);
...
{
...
MyFunc(Win);
...
}
This works fine, basically it boils down to:
movea.l Win,A0 (I may have the order wrong (A0, Win))
jsr _MyFunc
Now if I want to do the same thing, except MyFunc is a function pointer,
how do I do it?
extern __far __asm MyFunc(register __a0 struct Window *);
...
{
__fptr MyFunc;
...
MyFunc = SetFunction(...);
...
MyFunc(Win);
...
}
This doesn't work that way I want it to, it basically does the following:
pushal Win (Vax assembler ;-)
movea.l MyFunc,A0 (It just happend to use A0, I think)
jsr (A0)
(clean up the stack)
Anyway, It basically ignores the earlier declaration. What I want it for is,
I'm setfunctioning a routine, and if my new function fails, I want to call the
old function.
Don
-----------------------------------------------------------
Don R Withey BITNET: AXDRW@ALASKA.BITNET
University of Alaska BIX: dwithey
3211 U.A.A. Drive Phone: 907-786-1074 (work)
Anchorage, Alaska 99508 Phone: 907-344-4057 (home)
-----------------------------------------------------------bader+@andrew.cmu.edu (Miles Bader) (05/03/89)
AXDRW%ALASKA.BITNET@cunyvm.cuny.edu (Don R. Withey) writes: > How does one prototype a function pointer in Lattice 5.02? I have a function > pointer that I want to force Lattice to pass the arguments in certain > registers. For example: ... > Now if I want to do the same thing, except MyFunc is a function pointer, > how do I do it? > > extern __far __asm MyFunc(register __a0 struct Window *); > ... > { > __fptr MyFunc; > ... > MyFunc = SetFunction(...); > ... > MyFunc(Win); > ... > } > > This doesn't work that way I want it to, it basically does the following: ... Your code isn't quite clear, but declaring a local variable with the same name as a function declaration WON'T make the variable inherit the function's attributes. You probably want something like: { /* the declaration of func specifies all the desired attributes */ void __far __asm (*func)(register __a0 struct Window *); /* ... */ func=SetFunction(...); (*func)(Win); /* ... */ } -Miles