爲什麼我不能在afx(MFC)項目中包含windows.h?windows.h和MFC
7
A
回答
11
通常,MFC應用程序代碼包括afx.h
或afxwin.h
(後者包括前者)。的windows.h
前兩行是
#ifndef _WINDOWS_
#define _WINDOWS_
這意味着如果包括該標頭_WINDOWS_
變得定義。 Afx.h
包括afxver_.h
這頭包括afxv_w32.h
其中包含下面的代碼:
#ifdef _WINDOWS_
#error WINDOWS.H already included. MFC apps must not #include <windows.h>
#endif
...
#include <windows.h>
所以,如果你有windows.h
MFC頭之前,你會得到在編譯時產生這個錯誤,正如你所看到的,如果你包括afxwin.h
你自己不需要包含windows.h
- 它已包含在afxv_w32.h
之內。
2
因爲在MFC中你不應該直接使用它。 AFAIR你應該包含afx.h,而這又間接地包含了windows.h的正確方法。
相關問題
- 1. #error WINDOWS.H已包含在內。 MFC應用程序不能#include <windows.h>
- 2. Windows.h和鐺(LLVM)
- 3. 小寫windows.h和大寫windows.h的區別?
- 4. WINDOWS.H錯誤
- 5. 如何WINDOWS.H
- 6. 包括WINDOWS.H
- 7. windows.h - 嘟嘟聲()
- 8. C1189:#error:WINDOWS.H已包含在內。 MFC應用程序不能#包括<windows.h>
- 9. 的XCode WINDOWS.H和顯示彩色文字
- 10. MinGW Windows.h不編譯
- 11. 使用windows.h隨main()
- 12. Windows.h宏未定義
- 13. Windows.h線程關聯
- 14. Android上的windows.h庫
- 15. MFC winsock1和2
- 16. MFC和腳本?
- 17. 2008 MFC和線程?
- 18. 多線程和MFC
- 19. VC++和MFC應用
- 20. MFC的CFileDialog和lpstrInitialDir
- 21. VC++和MFC應用
- 22. WINDOWS.H已經包括錯誤
- 23. 包括「winmain.h」vs <windows.h>
- 24. C++ WINDOWS.H包括在Windows 10
- 25. 如何不#include <windows.h>
- 26. Visual Studio 2017找不到windows.h
- 27. Building Boost - 找不到windows.h
- 28. CRITICAL_SECTION並避免包括windows.h?
- 29. Windows.h未找到,爲什麼?
- 30. Windows.h找不到使用emscripten
什麼是錯誤信息? – fretje 2011-02-17 08:56:06