PRB: User-Defined onexit/atexit/cexit Not Called If /MD or /MDd (199521)



The information in this article applies to:

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

This article was previously published under Q199521

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.

Modification Type:MajorLast Reviewed:10/2/2003
Keywords:kbprb kbprogramming KB199521