BUG: Msvcrt.dll Does Not Initialize Global Objects

Article translations Article translations
Article ID: 192536 - View products that this article applies to.
This article was previously published under Q192536
Expand all | Collapse all

SYMPTOMS

When targeting Windows CE 2.00 and linking with C run-time dynamic libraries (Msvcrt.dll or Msvcrtd.dll), global C++ objects are not initialized.

RESOLUTION

If C++ global objects are being used, do not use the C run-time dynamic libraries. Use the static run-time libraries instead.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

The C run-time dynamic libraries were available only with Windows CE version 2.0. Devices using Windows CE version 1.0 or Windows CE 2.01 and later should not use these libraries. The following program demonstrates the 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;
   }
				

Properties

Article ID: 192536 - Last Review: November 18, 2003 - Revision: 2.0
APPLIES TO
  • 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
Keywords: 
kbbug kbpending KB192536

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com