Fix build with Borland C++ compiler.

Disable some parts of the code that this compiler had problems with. Add
parentheses to work around its bugs elsewhere.

Closes #12558.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66054 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-11-07 13:16:20 +00:00
parent 0ce0f1e9eb
commit 258593354e
13 changed files with 121 additions and 31 deletions

View File

@@ -119,6 +119,11 @@ extern WXDLLIMPEXP_DATA_CORE(wxBrushList*) wxTheBrushList;
// compilers as it compares elements of different enums
#if FUTURE_WXWIN_COMPATIBILITY_3_0
// Unfortunately some compilers have ambiguity issues when enum comparisons are
// overloaded so we have to disable the overloads in this case, see
// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
inline bool operator==(wxBrushStyle s, wxDeprecatedGUIConstants t)
{
return static_cast<int>(s) == static_cast<int>(t);
@@ -129,6 +134,8 @@ inline bool operator!=(wxBrushStyle s, wxDeprecatedGUIConstants t)
return !(s == t);
}
#endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
#endif // _WX_BRUSH_H_BASE_

View File

@@ -238,8 +238,15 @@
#if !wxUSE_UNICODE
#define wxT(x) x
#else /* Unicode */
/* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
#define wxT(x) wxCONCAT_HELPER(L, x)
/*
Notice that we use an intermediate macro to allow x to be expanded
if it's a macro itself.
*/
#ifndef wxCOMPILER_BROKEN_CONCAT_OPER
#define wxT(x) wxCONCAT_HELPER(L, x)
#else
#define wxT(x) wxPREPEND_L(x)
#endif
#endif /* ASCII/Unicode */
#endif /* !defined(wxT) */
@@ -250,7 +257,14 @@
builds everywhere (see wxStringCharType definition above).
*/
#if wxUSE_UNICODE_WCHAR
#define wxS(x) wxCONCAT_HELPER(L, x)
/*
As above with wxT(), wxS() argument is expanded if it's a macro.
*/
#ifndef wxCOMPILER_BROKEN_CONCAT_OPER
#define wxS(x) wxCONCAT_HELPER(L, x)
#else
#define wxS(x) wxPREPEND_L(x)
#endif
#else /* wxUSE_UNICODE_UTF8 || ANSI */
#define wxS(x) x
#endif

View File

@@ -28,6 +28,16 @@
/* a Unicode-friendly version of wxSTRINGIZE_T */
#define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x))
/*
Special workarounds for compilers with broken "##" operator. For all the
other ones we can just use it directly.
*/
#ifdef wxCOMPILER_BROKEN_CONCAT_OPER
#define wxPREPEND_L(x) L ## x
#define wxAPPEND_i64(x) x ## i64
#define wxAPPEND_ui64(x) x ## ui64
#endif /* wxCOMPILER_BROKEN_CONCAT_OPER */
/*
Helper macros for wxMAKE_UNIQUE_NAME: normally this works by appending the
current line number to the given identifier to reduce the probability of the

View File

@@ -1056,9 +1056,19 @@ typedef wxUint32 wxDword;
#define wxULongLong_t unsigned wxLongLong_t
#endif
/* these macros allow to define 64 bit constants in a portable way */
#define wxLL(x) wxCONCAT(x, wxLongLongSuffix)
#define wxULL(x) wxCONCAT(x, wxCONCAT(u, wxLongLongSuffix))
/*
wxLL() and wxULL() macros allow to define 64 bit constants in a
portable way.
*/
#ifndef wxCOMPILER_BROKEN_CONCAT_OPER
#define wxLL(x) wxCONCAT(x, wxLongLongSuffix)
#define wxULL(x) wxCONCAT(x, wxCONCAT(u, wxLongLongSuffix))
#else
// Currently only Borland compiler has broken concatenation operator
// and this compiler is known to use [u]i64 suffix.
#define wxLL(x) wxAPPEND_i64(x)
#define wxULL(x) wxAPPEND_ui64(x)
#endif
typedef wxLongLong_t wxInt64;
typedef wxULongLong_t wxUint64;

View File

@@ -378,6 +378,11 @@ extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList;
// compilers as it compares elements of different enums
#if FUTURE_WXWIN_COMPATIBILITY_3_0
// Unfortunately some compilers have ambiguity issues when enum comparisons are
// overloaded so we have to disable the overloads in this case, see
// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
inline bool operator==(wxFontFamily s, wxDeprecatedGUIConstants t)
{ return static_cast<int>(s) == static_cast<int>(t); }
inline bool operator!=(wxFontFamily s, wxDeprecatedGUIConstants t)
@@ -391,6 +396,8 @@ inline bool operator==(wxFontWeight s, wxDeprecatedGUIConstants t)
inline bool operator!=(wxFontWeight s, wxDeprecatedGUIConstants t)
{ return !(s == t); }
#endif // // wxCOMPILER_NO_OVERLOAD_ON_ENUM
#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
#endif

View File

@@ -30,18 +30,28 @@
namespace wxPrivate
{
// Helper macro to define a constant inside a template class: it's needed
// because MSVC6 doesn't support initializing static integer members but the
// usual workaround of using enums instead doesn't work for Borland (at least
// in template classes).
#ifdef __VISUALC6__
#define wxDEFINE_CLASS_INT_CONST(name, value) enum { name = value }
#else
#define wxDEFINE_CLASS_INT_CONST(name, value) static const int name = value
#endif
template<typename T>
struct TypeHierarchy
{
// consider unknown types (e.g. objects, pointers) to be of highest
// level, always convert to them if they occur
enum { level = 9999 };
wxDEFINE_CLASS_INT_CONST( level, 9999 );
};
#define WX_TYPE_HIERARCHY_LEVEL(level_num, type) \
template<> struct TypeHierarchy<type> \
{ \
enum { level = level_num }; \
wxDEFINE_CLASS_INT_CONST( level, level_num ); \
}
WX_TYPE_HIERARCHY_LEVEL( 1, char);
@@ -84,7 +94,7 @@ struct wxImplicitConversionType
typedef typename wxIf
<
// if T2 is "higher" type, convert to it
(int)wxPrivate::TypeHierarchy<T1>::level < (int)wxPrivate::TypeHierarchy<T2>::level,
(int)(wxPrivate::TypeHierarchy<T1>::level) < (int)(wxPrivate::TypeHierarchy<T2>::level),
T2,
// otherwise use T1
T1

View File

@@ -148,6 +148,11 @@ extern WXDLLIMPEXP_DATA_CORE(wxPenList*) wxThePenList;
// compilers as it compares elements of different enums
#if FUTURE_WXWIN_COMPATIBILITY_3_0
// Unfortunately some compilers have ambiguity issues when enum comparisons are
// overloaded so we have to disable the overloads in this case, see
// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
inline bool operator==(wxPenStyle s, wxDeprecatedGUIConstants t)
{
return static_cast<int>(s) == static_cast<int>(t);
@@ -158,6 +163,8 @@ inline bool operator!=(wxPenStyle s, wxDeprecatedGUIConstants t)
return !(s == t);
}
#endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
#endif // _WX_PEN_H_BASE_

View File

@@ -331,16 +331,38 @@
test for old versions of Borland C, normally need at least 5.82, Turbo
explorer, available for free at http://www.turboexplorer.com/downloads
*/
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x550)
# error "wxWidgets requires a newer version of Borland, we recommend upgrading to 5.82 (Turbo Explorer). You may at your own risk remove this line and try building but be prepared to get build errors."
#endif /* __BORLANDC__ */
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x582) && (__BORLANDC__ > 0x559)
# ifndef _USE_OLD_RW_STL
# error "wxWidgets is incompatible with default Borland C++ 5.6 STL library, please add -D_USE_OLD_RW_STL to your bcc32.cfg to use RogueWave STL implementation."
# endif
#endif /* __BORLANDC__ */
/*
Older versions of Borland C have some compiler bugs that need
workarounds. Mostly pertains to the free command line compiler 5.5.1.
*/
#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551)
/*
The Borland free compiler is unable to handle overloaded enum
comparisons under certain conditions e.g. when any class has a
conversion ctor for an integral type and there's an overload to
compare between an integral type and that class type.
*/
# define wxCOMPILER_NO_OVERLOAD_ON_ENUM
/*
This is needed to overcome bugs in 5.5.1 STL, linking errors will
result if it is not defined.
*/
# define _RWSTD_COMPILE_INSTANTIATE
/*
Preprocessor in older Borland compilers have major problems
concatenating with ##. Specifically, if the string operands being
concatenated have special meaning (e.g L"str", 123i64 etc)
then ## will not concatenate the operands correctly.
As a workaround, define wxPREPEND* and wxAPPEND* without using
wxCONCAT_HELPER.
*/
# define wxCOMPILER_BROKEN_CONCAT_OPER
#endif /* __BORLANDC__ */
/*
Define Watcom-specific macros.

View File

@@ -1385,7 +1385,8 @@ private:
{
if ( !m_pState )
return NULL;
return static_cast<const wxPropertyGrid*>(m_pState->GetGrid());
return m_pState->GetGrid();
}
friend class wxPropertyGrid;

View File

@@ -313,9 +313,6 @@ struct wxPixelDataOut<wxImage>
// the pixel format we use
typedef wxImagePixelFormat PixelFormat;
// the type of the pixel components
typedef typename PixelFormat::ChannelType ChannelType;
// the pixel data we're working with
typedef
wxPixelDataOut<wxImage>::wxPixelDataIn<PixelFormat> PixelData;
@@ -411,10 +408,10 @@ struct wxPixelDataOut<wxImage>
// -----------
// access to individual colour components
ChannelType& Red() { return m_pRGB[PixelFormat::RED]; }
ChannelType& Green() { return m_pRGB[PixelFormat::GREEN]; }
ChannelType& Blue() { return m_pRGB[PixelFormat::BLUE]; }
ChannelType& Alpha() { return *m_pAlpha; }
PixelFormat::ChannelType& Red() { return m_pRGB[PixelFormat::RED]; }
PixelFormat::ChannelType& Green() { return m_pRGB[PixelFormat::GREEN]; }
PixelFormat::ChannelType& Blue() { return m_pRGB[PixelFormat::BLUE]; }
PixelFormat::ChannelType& Alpha() { return *m_pAlpha; }
// address the pixel contents directly (always RGB, without alpha)
//

View File

@@ -118,7 +118,10 @@ private:
// Note that we use typedef instead of privately deriving from this (which
// would allowed us to omit "Ops::" prefixes below) to keep VC6 happy,
// it can't compile code that derives from wxIf<...>::value.
typedef typename wxIf< wxIsMovable<T>::value,
//
// Note that bcc needs the extra parentheses for non-type template
// arguments to compile this expression.
typedef typename wxIf< (wxIsMovable<T>::value),
wxPrivate::wxVectorMemOpsMovable<T>,
wxPrivate::wxVectorMemOpsGeneric<T> >::value
Ops;
@@ -452,7 +455,7 @@ namespace wxPrivate
// This is a helper for the wxVectorSort function, and should not be used
// directly in user's code.
template<typename T>
struct wxVectorSort
struct wxVectorComparator
{
static int wxCMPFUNC_CONV
Compare(const void* pitem1, const void* pitem2, const void* )
@@ -477,7 +480,7 @@ template<typename T>
void wxVectorSort(wxVector<T>& v)
{
wxQsort(v.begin(), v.size(), sizeof(T),
wxPrivate::wxVectorSort<T>::Compare, NULL);
wxPrivate::wxVectorComparator<T>::Compare, NULL);
}

View File

@@ -1500,8 +1500,8 @@ const wxString& wxTranslations::GetString(const wxString& origString,
TRACE_I18N,
"string \"%s\"%s not found in %slocale '%s'.",
origString,
n != UINT_MAX ? wxString::Format("[%ld]", (long)n) : wxString(),
!domain.empty() ? wxString::Format("domain '%s' ", domain) : wxString(),
(n != UINT_MAX ? wxString::Format("[%ld]", (long)n) : wxString()),
(!domain.empty() ? wxString::Format("domain '%s' ", domain) : wxString()),
m_lang
);

View File

@@ -77,7 +77,9 @@ wxXLocale& wxXLocale::GetCLocale()
{
if ( !gs_cLocale )
{
gs_cLocale = new wxXLocale(static_cast<wxXLocaleCTag *>(NULL));
// NOTE: bcc551 has trouble doing static_cast with incomplete
// type definition. reinterpret_cast used as workaround
gs_cLocale = new wxXLocale( reinterpret_cast<wxXLocaleCTag *>(NULL) );
}
return *gs_cLocale;