BUG: You receive many compilation error messages when you compile a Visual C++ application in Visual Studio 2005

This article has been archived. It is offered "as is" and will no longer be updated.
Consider the following scenario:
  • You create a Microsoft Visual C++ application in Microsoft Visual Studio 2005.
  • You include the following header files:
    • Windows.h
    • Gdiplus.h
In this scenario, when you compile the application, you receive many compilation error messages.
This problem occurs because the default Stdafx.h file defines the WIN32_LEAN_AND_MEAN constant. When this constant is defined, necessary definitions for the Gdiplus.h file are excluded.
To work around this problem, comment out or delete the following line of code in the Stdafx.h file of the Visual C++ application project.
#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

Steps to reproduce the problem

  1. Start Visual Studio 2005.
  2. On the File menu, point to New, and then click Project.
  3. Under Project types, click Visual C++.

    Note If you cannot see the Visual C++ project type, expand Other Languages, and then click Visual C++.
  4. Under Templates, click Win32 Console Application.
  5. Type a project name, and then click OK.
  6. Click Finish.
  7. Paste the following code in the code window.
    #include <windows.h>#include <gdiplus.h>
    Note Paste this code after the #include "stdafx.h" statement and before the int _tmain(int argc, _TCHAR* argv[]) statement.
  8. On the Build menu, click Build Solution. You receive the compilation error messages that are mentioned in the "Symptoms" section.

Article ID: 922323 - Last Review: 01/15/2015 15:09:56 - Revision: 1.0

Microsoft Visual Studio 2005 Team System Architect Edition, Microsoft Visual Studio 2005 Team System Developer Edition, Microsoft Visual Studio 2005 Team System Test Edition, Microsoft Visual Studio 2005 Team Foundation, Microsoft Visual Studio 2005 Standard Edition, Microsoft Visual Studio 2005 Professional Edition, Microsoft Visual Studio 2005 Express Edition

  • kbnosurvey kbarchive kbtshoot kbbug kbcode KB922323