C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

StackOverflow https://stackoverflow.com/questions/21725193

  •  10-10-2022
  •  | 
  •  

Вопрос

I'm building a C++ project which includes 2 libraries whom implicitly include for 2 times windows.h :

  1. afxwin.h
  2. atlbase.h (not sure)

Knowing that I need these two libraries into my project, how do I to get around this issue?

Any brilliant idea, please?

Это было полезно?

Решение

Try to hide mentioned libraries using some facade interface that these includes are not visible in the same compilation unit.

Другие советы

I encountered the same issue when building a Win32 app in visual studio 2010. A solution that worked for me was:

  1. Open stdafx.h
  2. Replace #include <windows.h> with #include <afxwin.h>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top