PRB: C2632 Caused by Including WINDOWS.H FirstLast reviewed: July 22, 1997Article ID: Q113062 |
7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbprg kbprb
The information in this article applies to:
SYMPTOMSCompiling a source file that explicitly includes WINDOWS.H followed by a Microsoft Foundation Classes (MFC) header file such as AFX.H may produce errors such as:
c2632 'long' followed by 'long' is illegal CAUSEThis error occurs as a result of MFC using STRICT type checking by default. STRICT type checking is not used in WINDOWS.H unless you define STRICT as a preprocessor symbol before including the header file. Specifically, WINDOWS.H has the following statement:
#ifdef STRICT typedef signed long LONG; #else #define LONG long #endifAFX.H has this statement:
typedef long LONG; // 32-bit signed numberAs you can see, if STRICT type checking is not used and WINDOWS.H is included before AFX.H, the typedef statement in AFX.H becomes the following (after preprocessing):
typedef long long; // 32-bit signed numberThe typedef statement is used to create another name for an existing data type. Because this statement has not specified a different name for the long data type, it is disallowed by the compiler.
RESOLUTIONInclude WINDOWS.H after the MFC header files or not at all. AFXWIN.H automatically includes WINDOWS.H, so it is normally not necessary to explicitly include it in your source code. Another way to avoid this error is to define STRICT as a preprocessor symbol before including WINDOWS.H. This will ensure that LONG is type defined as signed long rather than simply long.
MORE INFORMATIONMFC Technical Note 12 "Using Windows 3.1 Robustness Features" contains additional information on STRICT type checking and other Windows 3.1 robustness features.
Sample Code
/* Compile options needed: /D_WINDOWS */ /* #define STRICT // Remove comments from this line to avoid errors. */ #include <windows.h> // Or, reverse order of these statements. #include <afx.h> |
Additional reference words: 7.00 1.00 1.50 2.00 2.50 technote tech note
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |