Casting to far proc ptr

SUTHERLAND dwatney at pine.circa.ufl.edu
Sat Oct 6 05:17:33 AEST 1990


In article <2734 at crdos1.crd.ge.COM>, davidsen at crdos1.crd.ge.COM (Wm E Davidsen Jr) writes...
>  I need to pass to address of a procedure to a called function. The
>procedure is near static, and I need to cast to far, or assign the
>address to a far ptr.

The differences between near and far functions exist beyond the calling
routine.  the called function knows whether it is near or far and uses
the appropriate return.  so, in effect, the code you have now is probably
using a far call to a routine which in turn is using a near return.
A definite candidate for "undefined behavior", I would say, :)

But, you say, this doesn't solve my problem!  Well, how about this:
make a far function in the same segment as the function you want
which calls (near call) that function and then pass the pointer to
this new far funtion to whatever needs it?

client_function() far calls bridge_function() near calls desired_function()

-----
Marshall Sutherland, Partner/Consultant, Digital Magic Computer Consulting
dwatney at pine.circa.ufl.edu, dwatney at ufpine.bitnet
Sysop, Farthinghale Arms BBS, (904) 378-4861



More information about the Comp.lang.c mailing list