Article # 406, added by Geoworks, historical record
| first | previous | index | next | last |

Calling C functions using function pointers.



Q. I am having difficulty using far pointers to functions in PCGEOS.
   For example if a have a function with the prototype:

        void far _pascal MyFoo( int bogus1, int bogus2 );

   and a function pointer declared as:

        void (far _pascal * YourFoo)( int, int );

   the following assignment does not work correctly:

        YourFoo = MyFoo;

A. Since GEOS swaps memory around, your function pointer is actually
   a virtual pointer. You need to lock down the block that contains
   the routine (MyFoo) before making the function call. You can do
   this in one of two ways:

        YourFoo = MemLockFixedOrMovable( MyFoo );
        (*YourFoo)( bog1, bog2 );
        MemUnlockFixedOrMovable( MyFoo );

   or

	YourFoo = MyFoo;
	ProcCallFixedOrMovable_pascal( bog2, bog1, YourFoo );
	/* note that parameters are in reverse order */