Bitcointalk · A few suggestions

中本聪,2009 年 12 月 14 日

SN-0050 已核对来源,附原文与上下文。

阅读语言
中文译文

有人能指点一下吗?

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, std::allocator >&)' /usr/local/include/wx-2.8/wx/textctrl.h:303: note: candidates are: virtual void wxTextCtrlBase::SetValue(const wxString&)

看起来 std::string 到 wxString 的隐式转换不工作。这转换到处都在用,必须能用。

wxString 情况复杂,因为要同时支持 win32 的 16 位 wchar 和 8 位 ansi 双编译。Windows 上如果用了 "unicode"(即 wchar)构建,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__"

ORIGINAL · 英文原文
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__"
来源
Bitcointalk 原始链接 ↗ 记录编号 SN-0050