KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Article: Q32891
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 19-JUL-1988

Problem:
   I am attempting to write a function to be used in a dynamic link
library. The function returns a double. Whenever I compile and link
with either of the multithread C run-time libraries (LLIBCMT.LIB
or CRTLIB.LIB), I get the variable __fac unresolved.

Response:
   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.
   If you are writing functions that return doubles and you are using
the multithread libraries, you need to 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.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.