wxWidgets和boost :: property_tree之间的冲突

时间:2014-12-16 18:38:02

标签: c++ boost wxwidgets

我想在wxWidgets应用程序中使用boost :: property_tree。

但是当我添加行

#include <boost/property_tree/ptree.hpp>

到一个简单的wxWidgets我突然遇到编译错误:

||=== Build: Release in pulley_client_gui (compiler: GNU GCC Compiler) ===|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h||In function 'HWND__* CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC)':|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h|38|error: cannot convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'HWND__* CreateDialogParamW(HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM)'|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h||In function 'HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR)':|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h|69|error: cannot convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}' for argument '14' to 'HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCWSTR)'|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h||In function 'HWND__* CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)':|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h|94|error: cannot convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'HWND__* CreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)'|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h||In function 'HMENU__* LoadMenu(HINSTANCE, LPCTSTR)':|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h|111|error: cannot convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'HMENU__* LoadMenuW(HINSTANCE, LPCWSTR)'|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h||In function 'HICON__* LoadIcon(HINSTANCE, LPCTSTR)':|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h|311|error: cannot convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'HICON__* LoadIconW(HINSTANCE, LPCWSTR)'|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h||In function 'HBITMAP__* LoadBitmap(HINSTANCE, LPCTSTR)':|
C:\Users\James\code\wxWidgets-3.0.1\include\wx\msw\winundef.h|324|error: cannot convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'HBITMAP__* LoadBitmapW(HINSTANCE, LPCWSTR)'|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===|

这似乎表明wxWidgets方法无法再处理UTF8参数,转换为UTF16的能力已被boost头文件破坏。

2 个答案:

答案 0 :(得分:0)

找到了解决方法。如果我在wxWidgets标题之后包含boost标题,那么编译就成功了。

答案 1 :(得分:0)

似乎UNICODE定义不一致,即当<windows.h>包含在Boost标头中并且未定义(或是)包含wxWidgets标头时定义(或不​​定义)。

为防止这种情况发生,建议的解决方案是在make或项目文件中定义UNICODE,以便在命令行中定义它。您可能已在那里定义_UNICODE(如果使用MSVS项目),但这只会影响CRT标题,UNICODE也需要<windows.h>

相关问题