Typically, the MFC application code includes afx.h or afxwin.h (the latter includes the former). The first two lines of windows.h are equal
#ifndef _WINDOWS_ #define _WINDOWS_
which means that _WINDOWS_ becomes definable if this header is included. afx.h includes afxver_.h , and this header includes afxv_w32.h , which contains the following code:
#ifdef _WINDOWS_ #error WINDOWS.H already included. MFC apps must not #include <windows.h> #endif ... #include <windows.h>
So, if you included windows.h in front of the MFC headers, you will get this error generated at compile time, and, as you can see, if you enable afxwin.h , you do not need to enable windows.h yourself - it will already be included afxv_w32.h .
Bojan komazec
source share