[wxMac 2.8.4, wxMSW ?] "Strange" Mac g++ compiler errors trying to compile Windows compilable wx code

David Goldsmith David.L.Goldsmith at noaa.gov
Wed Jun 20 19:17:24 PDT 2007


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/>




More information about the wx-users mailing list