PRB: __fac Unresolved at Link Time

ID Number: Q32891

5.10 6.00 6.00a 6.00ax | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

In Microsoft C versions 5.1, 6.0, 6.0a, and 6.0ax, when attempting

to write a function to be used in a dynamic-link library (DLL), the

function returns a double. When the function is compiled and linked

with one of the multithread C run-time libraries (LLIBCMT.LIB,

CRTLIB.LIB, or CEXAMPLE.LIB), the variable __fac is unresolved.

CAUSE

In a single thread environment, the C run time uses a global

variable __fac to store the return value of a function that returns

double. In a multithread reentrant environment, it is not possible

to have a global variable that will potentially be modified by

several threads.

RESOLUTION

If you are writing functions that return doubles and you are using

the multithread libraries, you must declare the functions with the

Pascal calling convention. Functions returning double with the

Pascal calling convention pass the return value on the stack and

allow you to work in a reentrant environment.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax