原始文献 / 论坛帖 / Re: A few suggestions

Re: A few suggestions

Bitcointalk · 2009-12-14 17:15:56 UTC

AuthorSatoshi Nakamoto
TitleRe: A few suggestions
Date2009-12-14 17:15:56 UTC
ForumBitcointalk · 原文

引用自:madhatter2,2009 年 12 月 14 日 03:01:39 PM(https://bitcointalk.org/index.php?topic=12.msg66#msg66)

有人能指点一下吗?

(以下编译错误日志保留英文原文:)

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&)

看起来 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

"Mac OS 有两个 wxWidgets 移植版。其中 wxMac 有两个版本:Classic 和 Carbon。Classic 版是唯一能在 Mac OS 8 上跑的。Carbon 版可以编成 CFM 或 Mach-O(二进制格式,类似 ELF),前者能在 OS 9 下跑,后者只能跑在 OS X。最后还有一个新的 Cocoa 移植版,只能用在 OS X。总结如下:

* 如果要检测所有 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(https://bitcointalk.org/index.php?topic=12.msg66#msg66)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__"