MinGW包含代码块和Windows标头

时间:2016-05-29 19:08:46

标签: codeblocks mingw-w64

我使用Mingw作为编译器的代码块。我正在开发一个win32项目(winapi).. 问题似乎是codeblocks无法访问某些Windows标头... 在我的特殊情况下,缺少的头文件是commdlg.h并且在该头文件中使用了一个变量,编译器给出了错误:该变量未在此范围内声明...

那么如何使用Mingw使代码块具有所有必需的Windows头文件? 代码是

bool Gui::_browseForFile(HWND owner, LPWSTR initialDir, LPWSTR   fileBuffer)
{
OPENFILENAMEW ofn;
Mem::_zero(&ofn, sizeof(OPENFILENAMEW));

ofn.lStructSize     = sizeof(OPENFILENAMEW);
ofn.hwndOwner       = owner;
ofn.lpstrFile       = fileBuffer;
ofn.nMaxFile        = MAX_PATH;
ofn.lpstrInitialDir = initialDir;   
ofn.Flags           = OFN_DONTADDTORECENT | OFN_ENABLESIZING |  OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;

return CWA(comdlg32, GetOpenFileNameW)(&ofn) ? true : false;
}

现在构建日志是

-------------- Build: Debug in NewZe (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -std=c++11 -g -masm=intel -g -masm=intel -std=c++11 -g  -c C:\Users\mike\Desktop\workspace\NewZe\gui.cpp -o obj\Debug\gui.o
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp: In function 'HWND__* Gui::_windowFromPoint(POINT, DWORD, DWORD*)':
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:56:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     else if(result == HTTRANSPARENT)
                    ^
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp: In function 'bool Gui::_browseForFile(HWND, LPWSTR, LPWSTR)':
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:146:25: error: 'OFN_DONTADDTORECENT' was not declared in this scope
   ofn.Flags           = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
                         ^
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp: In function 'bool Gui::_browseForSaveFile(HWND, LPWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD)':
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:163:25: error: 'OFN_DONTADDTORECENT' was not declared in this scope
   ofn.Flags           = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
                         ^
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp: In function 'bool Gui::_loadCommonControl(DWORD)':
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:182:3: error: 'INITCOMMONCONTROLSEX' was not declared in this scope
   INITCOMMONCONTROLSEX cc;
   ^
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:184:3: error: 'cc' was not declared in this scope
   cc.dwSize = sizeof(INITCOMMONCONTROLSEX);
   ^
In file included from C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:8:0:
C:\Users\mike\Desktop\workspace\NewZe\defines.h:3:39: error: '::InitCommonControlsEx' has not been declared
 #define CWA(dll, api)                 ::api
                                       ^
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:187:11: note: in expansion of macro 'CWA'
   return (CWA(Comctl32, InitCommonControlsEx)(&cc) == TRUE);
           ^
C:\Users\mike\Desktop\workspace\NewZe\gui.cpp:188:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

0 个答案:

没有答案