← Back to team overview

kicad-developers team mailing list archive

I hate even more wxString

 

Every wx releases something works slightly different...

I'm trying to use wx 2.9.4 (installed with the wxPython distribution)
Configured OK, building woes:


static int wxCALLBACK MyCompareFunction( long aItem1, long aItem2, long aSortData )
{  
    wxString* component1Name = (wxString*) aItem1;
    wxString* component2Name = (wxString*) aItem2;
    
    return StrNumCmp( *component1Name, *component2Name, 
                      INT_MAX, true ); 
}


StrNumCmp takes two const wxChar* so I presume the idea was to use some kind of internal autoconversion of wxString to const wxChar* (I don't know if it exists... where it a std::string you would have to use c_str() or similar). However g++ spit out this:

error: cannot convert 'wxString' to 'const wxChar* {aka const wchar_t*}' for argument '1' to 'int StrNumCmp(const wxChar*, const wxChar*, int, bool)'

... now, I know that this can be fixed using GetChars, but WHY it worked on 2.8 and nobody else with 2.9 encountered this???

Another 'funny' thing: I have in my text drawing routine used the '\' character to do an escape to the Technical Set 1. So I have an int called escape_base containing the offset if the escape is in effect. The incriminated line is:

AsciiCode = aText.GetChar( ptr ) + escape_base;

AsciiCode is an int too, BTW. In its holyness g++ complains:

error: ambiguous overload for 'operator+' in '(& aText)->wxString::GetChar(((size_t)ptr)) + escape_base

So we have a wxUniChar (in 2.9 it's a class!) and an int. However the rules for conversion are... uhm... involved... so there are 18 (EIGHTEEN) fscking operator + to choose from... so I need to 'clarify' using int(aText.GetChar(ptr))

Hate hate hate

Does it happen only to me???

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups