FIX: Using #define NOGDI Results in Compilation Syntax Errors

Last reviewed: September 19, 1997
Article ID: Q148318
The information in this article applies to:
  • Microsoft Visual C++, 32-bit Edition, versions 2.2, 4.0, 4.1, 4.2

SYMPTOMS

Compiling a source file that contains the following code:

   #define NOGDI
   #include <windows.h>

results in several syntax errors such as these:

   winuser.h(8577) : error C2501: 'LOGFONTA' : missing decl-specifiers
   winuser.h(8577) : error C2146: syntax error : missing ';'  before
   identifier 'lfFont'

CAUSE

GDI-specific types like LOGFONTA are not defined when NOGDI is defined. However, header files like Winuser.h and Imm.h have structures that contain the GDI-specific types without the surrounding "#ifndef NOGDI"/"#endif" pair. The compiler generates syntax error for the GDI-specific types inside these structures.

RESOLUTION

Do not use #define NOGDI, or edit the system header files that produce the syntax errors to add the "#ifndef NOGDI"/"#endif" pair around the structures that contain the GDI-specific types.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.

Keywords          : vcbuglist400 vcfixlist500 VCGenIss kbprg
Version           : 2.2 4.0 4.1 4.2
Platform          : NT WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


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


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.

Last reviewed: September 19, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.