From ae51cebbe62f759cdee2f4548249393472b7baa5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 11 Jun 2007 19:57:01 +0000 Subject: [PATCH] compilation fix for gcc 3.3 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/wxcrt.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/include/wx/wxcrt.h b/include/wx/wxcrt.h index 6cb71114de..72e36a6c22 100644 --- a/include/wx/wxcrt.h +++ b/include/wx/wxcrt.h @@ -414,18 +414,37 @@ inline int wxStricmp_String(const wxString& s1, const T& s2) { return s1.CmpNoCase(s2); } WX_STRCMP_FUNC(wxStricmp, wxCRT_StricmpA, wxCRT_StricmpW, wxStricmp_String) + +// GCC 3.3 has a bug that causes it to fail compilation if the template's +// implementation uses overloaded function declared later (see the wxStrcoll() +// call in wxStrcoll_String()), so we have to forward-declare the template +// and implement it below WX_STRCMP_FUNC. OTOH, this fails to compile with VC6, +// so we do it for GCC only. +#ifdef __GNUG__ +template +inline int wxStrcoll_String(const wxString& s1, const T& s2); +WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String) +#endif // __GNUG__ + template inline int wxStrcoll_String(const wxString& s1, const T& s2) { #if wxUSE_UNICODE // NB: strcoll() doesn't work correctly on UTF-8 strings, so we have to use - // wc_str() even if wxUSE_UNICODE_UTF8: - return wxStrcoll(s1.wc_str(), s2); + // wc_str() even if wxUSE_UNICODE_UTF8; the (const wchar_t*) cast is + // there just as optimization to avoid going through + // wxStrcoll: + return wxStrcoll((const wchar_t*)s1.wc_str(), s2); #else - return wxStrcoll(s1.mb_str(), s2); + return wxStrcoll((const char*)s1.mb_str(), s2); #endif } + +#ifndef __GNUG__ +// this is exactly the same WX_STRCMP_FUNC line as above wxStrcoll_String<> WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String) +#endif + template inline int wxStrspn_String(const wxString& s1, const T& s2) -- 2.45.2