KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q199521: PRB: User-Defined onexit/atexit/cexit Not Called If /MD or /MDd

Article: Q199521
Product(s): Microsoft C Compiler
Version(s): MACINTOSH:4.0,4.0b
Operating System(s): 
Keyword(s): kbprogramming kbHWMAC kbVC kbDSupport
Last Modified: 06-FEB-2000

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual C++, Macintosh Cross-Development Addon, versions 4.0, 4.0b 
-------------------------------------------------------------------------------

SYMPTOMS
========

User-defined onexit, atexit, and cexit routines are not called for PowerMac
applications using the C run-time dynamic-link library (DLL), /MD or /MDd.

CAUSE
=====

DLLs and applications have different arrays of onexit pointers. The Win32
libraries have a method for ensuring both arrays are run through when the
application terminates; however, this was not put in place for PowerMac DLLs.

Also, note that special handling is required for user-built DLLs!

RESOLUTION
==========

Following are some possible ways to resolve this problem:

- Use the static version instead of the DLL version of the C run-time
  libraries.

- Clean up in the destructor of a global C++ object.

Additional query words: _cexit cexit _onexit

======================================================================
Keywords          : kbprogramming kbHWMAC kbVC kbDSupport 
Technology        : kbVCsearch kbHWMAC kbOSMAC kbAudDeveloper kbVCXDev400Mac kbVCXDev400bMac
Version           : MACINTOSH:4.0,4.0b
Issue type        : kbprb

=============================================================================

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.