开发者

Why does my call to 'wxGetTranslation' result in the compiler error "ambiguous call to overloaded function"?

开发者 https://www.devze.com 2023-03-14 12:17 出处:网络
c:\\wxwidgets-2.8.11\\include\\wx\\filename.h(497): error C2668: \'wxGetTranslation\' : ambiguous call to overloaded function
c:\wxwidgets-2.8.11\include\wx\filename.h(497): error C2668: 'wxGetTranslation' : ambiguous call to overloaded function
          c:\bitcoin\src\util.h(191): could be 'const char *wxGetTranslation(const char *)'
          c:\wxwidgets-2.8.11\include\wx\intl.h(579): or       'const wxChar *wxGetTranslation(const wxChar *,const wxChar *)'
          while trying to match the argument list '(const char [14])'
wxString GetHumanReadableSize(
    const wxString &nullsize = wxGetTranslation(wxT("Not available")),
    int precision = 1) const;

I don't see how that is ambiguous at all? One takes 1 arg and the other 2. That file is calling it with 1 a开发者_开发知识库rg.


That's because the other function has 2nd parameter as default argument. See here I have simulated the same effect. Unfortunately compiler doesn't show the default argument inside the error message:

//intl.h
const wxChar *wxGetTranslation(const wxChar *c1, const wxChar *c2 = <something>);

More precisely,

void foo (const char* c1);  // 1st
void foo (const char* c1, const char *c2 = 0);  // 2nd

would create ambiguity when you try to call the 1st version, because 2nd version is also an equally well candiate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号