Why can't I include windows.h in afx(MFC) projects?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Because in MFC you are not supposed to use it directly. AFAIR you should include afx.h instead, which in turn indirectly includes windows.h the proper way.
Typically, MFC application code includes
afx.h
orafxwin.h
(the latter includes former). First two lines ofwindows.h
arewhich means that
_WINDOWS_
becomes defined if this header is included.Afx.h
includesafxver_.h
and this header includesafxv_w32.h
which contains following code:So, if you include
windows.h
before MFC headers, you'll get this error generated in compile time and, as you can see, if you includeafxwin.h
you don't need to includewindows.h
yourself - it will already be included byafxv_w32.h
.