[wxMac 2.8.4, wxMSW ?] "Strange" Mac g++ compiler errors trying to
compile Windows compilable wx code
David L Goldsmith
David.L.Goldsmith at noaa.gov
Thu Jun 21 07:39:13 PDT 2007
Scratch that, just found the FAQ on this.
DG
David L Goldsmith wrote:
> Oh, and does wxT work "correctly" in either build? Thanks!
>
> DG
>
> Eran Ifrah wrote:
>> The problem is that you are using unicode version of wx and it using
>> ANSI build.
>> strData.c_str() will return wxChar which defined as wchar_t on
>> unicode build.
>>
>> So, use any of the conversion functions available:
>>
>> for example, instead of using strData.c_str(), try strData.ToAscii()
>>
>> Eran
>>
>>
>> On 6/21/07, *David Goldsmith* < David.L.Goldsmith at noaa.gov
>> <mailto:David.L.Goldsmith at noaa.gov>> wrote:
>>
>> Hi, folks! I'm trying to compile some wx C++ code written by a
>> colleague; I'm working late so can't consult him, but seeing as
>> how he's
>> primarily a Windows developer and the code in question compiles
>> thereon,
>> I'm not sure how much he'd be able to help me figure out why I'm
>> having
>> the problems I'm having trying to do it on a Mac w/ g++.
>>
>> The first "symptom" was the compiler complaining about an overloaded
>> method ambiguity:
>>
>> "error: call of overloaded 'wxString(const char [33])' is ambiguous"
>>
>> Here's the problem line of code:
>>
>> wxMessageBox(wxString("Vertex data file was not opened."),
>> wxT("Vertex File Reading Error Message"), wxOK |
>> wxICON_ERROR);
>>
>> Again, I emphasize that AFAIK this compiles fine in Windows (he uses
>> VC++, most current version, so what ever version of MicroSoft's C++
>> compiler that implies...) I guessed correctly - at least as far as
>> getting it to compile is concerned - that the fix was to replace
>> wxString with wxT; there were multiple occurrences of this problem
>> so I
>> just replaced all occurrences of wxString( with wxT( and that
>> fixed that.
>>
>> Then I ran into (multiple instances of) the following:
>>
>> error: cannot convert 'const wxChar*' to 'const char*' for
>> argument '1'
>> to 'int sscanf(const char*, const char*, ...)'
>>
>> Here's a sample problem line of code:
>>
>> if(sscanf(strData.c_str(),"%ld, %lf, %lf, %lf", &pointNumber,
>> &longitude, &latitude, &depth) < 4)
>>
>> so sscanf wants argument 1 to be a const char* but the compiler
>> thinks
>> it's getting a const wxChar*; but isn't c_str() the method that
>> returns
>> the char* member of a wxChar object? In any event, I seems MS's
>> compiler can deal w/ this but apparently g++ can't.
>>
>> My working hypothesis (which I can't check w/ my colleague 'til
>> tomorrow) is that he's using an older version of wx - would that
>> explain
>> these problems? Or is it another instance of MS's compiler being
>> too
>> permissive and we need to write our code more strictly? If
>> neither of
>> these, what? (As I said, I'd say it's about a 50/50 chance that
>> he'd
>> know the origin of the discrepancy.)
>>
>> Thanks!
>>
>> DG
>> --
>> ERD/ORR/NOS/NOAA
>> <http://response.restoration.noaa.gov/emergencyresponse/ >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>> <mailto:wx-users-unsubscribe at lists.wxwidgets.org>
>> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>> <mailto:wx-users-help at lists.wxwidgets.org>
>>
>>
>>
>>
>> --
>> Eran Ifrah
>> eran.ifrah at gmail.com <mailto:eran.ifrah at gmail.com>
>
--
ERD/ORR/NOS/NOAA <http://response.restoration.noaa.gov/emergencyresponse/>
More information about the wx-users
mailing list