Skip to content

回复:一些建议 ​

原始发布页

打开来源页面
查看 1 个交叉存档

引用 madhatter2 于 2009 年 12 月 14 日 03:01:39 PM 的发言

有人能解释一下这里的情况吗?

g++ -c -O0 -Wno-invalid-offsetof -Wformat -g -D**__WXMAC__** -DNOPCH -DBUILD_MACOSX -I"/usr/include" -I"/usr/local/include/wx-2.8" -I"/usr/local/include" -I"/usr/local/boost_1_41_0" -I"/sw/include/db4" -I"/usr/local/ssl/include" -I"/usr/local/lib/wx/include/mac-ansi-release-2.8" -o headers.h.gch headers.h ... ui.h:430: 错误:没有与 'wxTextCtrl::SetValue(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)' 调用匹配的函数 /usr/local/include/wx-2.8/wx/textctrl.h:303: 注:候选函数为:virtual void wxTextCtrlBase::SetValue(const wxString&)

看起来从 std::string 到 wxString 的隐式转换没有生效。这个转换到处都在使用,必须让它生效。

wxString 因为要支持 win32 的 16 位 wchar 和 8 位 ansi 双重编译而很复杂。如果使用“unicode”(意指 wchar)构建,在 Windows 上也可能遇到这个问题,此时 wxString 是 wchar,而 std::string 是 char。

这可能是某些 wxWidgets 编译定义或构建配置造成的。你使用了哪些 "configure" 选项?

我不确定 __WXMAC__ 是正确的定义。它可能是 Mac Classic 支持,导致 wxString 变得复杂,而我们只需要 OSX。试试 __WXOSX__(或参见下文)

http://docs.wxwidgets.org/stable/wx_cppconst.html “wxWidgets 有两个面向 Mac OS 的移植版。其中一个 wxMac 有两个版本:Classic 和 Carbon。Classic 版本是唯一能在 Mac OS 版本 8 上运行的版本。Carbon 版本既可以构建为 CFM,也可以构建为 Mach-O(二进制格式,类似 ELF);前者可以在 OS 9 下运行,而后者只能在 OS X 下运行。最后,还有一个只能在 OS X 下使用的新 Cocoa 移植版。总结如下:

* 如果想检测所有 Mac 平台,包括 classic 和 OS X,应同时检测 __WXMAC__ 和 __WXCOCOA__。 * 如果想检测 OS X 下的任何 GUI Mac 移植版,请使用 __WXOSX__。 * 如果想检测 Mac OS X 下的任何移植版,包括例如 wxGTK 以及 wxBase,请使用 __DARWIN__”

英文原文 ​

展开英文原文

Quote from: madhatter2 on December 14, 2009, 03:01:39 PM

Can anyone shed some light here?

g++ -c -O0 -Wno-invalid-offsetof -Wformat -g -D**__WXMAC__** -DNOPCH -DBUILD_MACOSX -I"/usr/include" -I"/usr/local/include/wx-2.8" -I"/usr/local/include" -I"/usr/local/boost_1_41_0" -I"/sw/include/db4" -I"/usr/local/ssl/include" -I"/usr/local/lib/wx/include/mac-ansi-release-2.8" -o headers.h.gch headers.h ... ui.h:430: error: no matching function for call to 'wxTextCtrl::SetValue(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)' /usr/local/include/wx-2.8/wx/textctrl.h:303: note: candidates are: virtual void wxTextCtrlBase::SetValue(const wxString&)

It looks like the implicit conversion from std::string to wxString isn't working. That's used everywhere, the conversion needs to work.

wxString is complicated by supporting win32's 16-bit wchar and 8-bit ansi dual-compile. You can get that problem on Windows if the "unicode" (meaning wchar) build is used, so that wxString is wchar and std::string is char.

It's probably some wxWidgets compile defines or build configuration. What "configure" options did you use?

I'm not sure __WXMAC__ is the right define. It may be the Mac Classic support that's complicating wxString, and we only want OSX. Try __WXOSX__ (or see below)

http://docs.wxwidgets.org/stable/wx_cppconst.html "There are two wxWidgets ports to Mac OS. One of them, wxMac, exists in two versions: Classic and Carbon. The Classic version is the only one to work on Mac OS version 8. The Carbon version may be built either as CFM or Mach-O (binary format, like ELF) and the former may run under OS 9 while the latter only runs under OS X. Finally, there is a new Cocoa port which can only be used under OS X. To summarize:

* If you want to test for all Mac platforms, classic and OS X, you should test both __WXMAC__ and __WXCOCOA__. * If you want to test for any GUI Mac port under OS X, use __WXOSX__. * If you want to test for any port under Mac OS X, including, for example, wxGTK and also wxBase, use __DARWIN__"

为历史保存,为中文读者整理。每篇档案均附来源与英文原文。