BUG: Msvcrt.dll Does Not Initialize Global Objects

This article was previously published under Q192536
This article has been archived. It is offered "as is" and will no longer be updated.
When targeting Windows CE 2.00 and linking with C run-time dynamiclibraries (Msvcrt.dll or Msvcrtd.dll), global C++ objects are notinitialized.
If C++ global objects are being used, do not use the C run-time dynamiclibraries. Use the static run-time libraries instead.
Microsoft has confirmed this to be a bug in the Microsoft products listedat the beginning of this article.
The C run-time dynamic libraries were available only with Windows CEversion 2.0. Devices using Windows CE version 1.0 or Windows CE 2.01 andlater should not use these libraries. The following program demonstratesthe problem when linked with Msvcrt or Msvcrtd:
   // Sample.cpp -   //    // Should show the constructor message before the main program   // message. Instead, the constructor message isn't shown at all.   //    #include <windows.h>   #define MSG(z) MessageBox(0,z,TEXT("Sample"),MB_OK)   struct MYCLASS   {      MYCLASS()   { MSG(TEXT("Constructor called.")); }   };   MYCLASS myclass;   int WINAPI WinMain(      HINSTANCE   hInstance,      HINSTANCE   hPrevInstance,      LPTSTR      lpCmdLine,      int         nCmdShow)   {      MSG(TEXT("Main program."));      return 0;   }				

Article ID: 192536 - Last Review: 01/06/2015 03:43:39 - Revision: 2.0

  • Microsoft Windows CE Toolkit for Visual C++ 6.0
  • Microsoft Windows CE Embedded Toolkit for Visual C++ 5.0
  • Microsoft Windows CE Platform Builder 2.11
  • kbnosurvey kbarchive kbbug kbpending KB192536