Q:  I'm getting a GPF (Message is: 'Stack Fault in module <DLL name> at <address>') when my Delphi app calls a function in a DLL. (It's probably a C or C++ DLL) The function returns the value of a floating-point variable in another application, and is described as follows:

float <function name>(ACCID accID, HPT hPt)

Return value is a 32-bit IEEE floating point number.

The return value is read into a variable of type single. The DLL vendor tells me that the floating point value returned might be incompatible with Borland's floating point format. Any idea as to why this is happening?

A:  It's not a question of the floating-point format. Instead, the problem is that Microsoft compilers return floating-point values in a different manner from that of Borland compilers. Here's Pat's standard MS vs. Borland FP result message (it talks about Excel, but it applies to MS compilers in general):

When a "B" format is specified as the function result for a registered function in Excel,  Excel passes a near pointer (SS relative) that is the location to store the result of function.  In addition Excel expects a far pointer to be returned that specifies the address of the result.  So for a function registered as "BBB" where you THINK the function heading SHOULD be:

   function MyFunc(d1,d2 : double) : double; export;

the actual Turbo Pascal function actually is:

   function MyFunc(d1,d2 : double; NearPtr : word) : pointer; export;

So that results are returned as expected, a temporary pointer variable is used with the address established as outline above.  The body of the function would be:

   var
     Temp : ^double;
   begin
     MyFunc := Ptr(SSeg,NearPtr); { what Excel expects to be returned }
     Temp := Ptr(SSeg,NearPtr);
     Temp^ := d1+d2; { or whatever your function needs to do }
   end;