// 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);
return !(s == t);
}
+#endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
+
#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
#endif // _WX_BRUSH_H_BASE_
#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) */
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
/* 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
#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;
// 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)
inline bool operator!=(wxFontWeight s, wxDeprecatedGUIConstants t)
{ return !(s == t); }
+#endif // // wxCOMPILER_NO_OVERLOAD_ON_ENUM
+
#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
#endif
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);
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
// 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);
return !(s == t);
}
+#endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
+
#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
#endif // _WX_PEN_H_BASE_
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.
{
if ( !m_pState )
return NULL;
- return static_cast<const wxPropertyGrid*>(m_pState->GetGrid());
+
+ return m_pState->GetGrid();
}
friend class wxPropertyGrid;
// 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;
// -----------
// 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)
//
// 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;
// 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* )
void wxVectorSort(wxVector<T>& v)
{
wxQsort(v.begin(), v.size(), sizeof(T),
- wxPrivate::wxVectorSort<T>::Compare, NULL);
+ wxPrivate::wxVectorComparator<T>::Compare, NULL);
}
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
);
{
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;