I've been working on a static library. Everything was fine until a couple of days ago. Then I started getting the following error message:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\atlmfc\include\afxv_w32.h(16,1): fatal error C1189: #error: WINDOWS.H already included. MFC apps must not #include <Windows.h>
I have only one .cpp file that requires <windows.h> for access to the console routines. For some reason VS thinks I'm using MFC. As far as I know, I'm not.
I can find only one setting in the project property pages related to MFC.
USE MFC: { Use Standard Windows Libraries | Use MFC in a Static Library | Use MFC in a Shared DLL | <inherit from parent or project defaults> }
I've tried all four settings, all four result in an error.
Edit to add:
USE STANDARD LIBRARIES, USE SHARED DLL amd INHERIT PROJECT DEFAULTS all result in the above message.
USE MFC IN STATIC LIBRARY results in
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\atlmfc\include\afxver_.h(77,1): fatal error C1189: #error: Please use the /MD switch for _AFXDLL builds
I've tried creating the project from scratch and still get the same errors.
I have a CONSOLE class that serves as a wrapper for the Windows API console calls.
Other than my own includes and the needed C++ libraries, I'm including <windows.h> in the projlib.h file which includes console.h because console.h needs HANDLE.
Edit:
I've narrowed it down to my projlib.h header. I have a couple of simple shape classes that only include their own headers and they compile fine. If I use my projlib.h header, they fail with the one of the above messages.
Thanks for the suggestion. <windows.h> has it's own include guards so the second #include will have no effect.
I went back to your turboscreen\main.cpp example and that compiles just fine. When I look at the property pages for that project there is no USE MFC option.
So something in my code is triggering the USE MFC option which seems to be the problem.
VC++ win32 project, win32 console application or MFC project ?
Go to project properties.
Maybe your project file is corrupted.
afxv_w32.h has a <windows.h> in it ?
i saw this in a forum
There is #include "windows.h" somewhere in your stdafx.h. Replace it with afxwin.h, include afxinet.h after that and set "this project uses MFC" in project settings; then try to build.
@forgottencoder - Thanks for the link. That was helpful. I replaced the #include of <windows.h> with the following four lines and everything now compiles.