From 6d3d756a6a3a174a23d987f399841a04c879acfa Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Thu, 10 Nov 2005 16:16:05 +0000 Subject: [PATCH] Macros for simplified testing Open Watcom version and required tweaks. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 6 +++--- include/wx/filefn.h | 4 ++-- include/wx/msw/chkconf.h | 10 ++-------- include/wx/msw/gccpriv.h | 2 +- include/wx/os2/private.h | 3 +-- include/wx/palmos/chkconf.h | 3 +-- include/wx/platform.h | 19 +++++++++++++++++-- src/common/filefn.cpp | 5 ++--- src/common/imagjpeg.cpp | 10 ++-------- src/common/imagpng.cpp | 2 +- src/common/textbuf.cpp | 4 +--- 11 files changed, 33 insertions(+), 35 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 38f9991510..c9d7f22c3e 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -146,7 +146,7 @@ #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x500) /* Borland 5.0+ supports bool */ #define HAVE_BOOL - #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) + #elif wxCHECK_WATCOM_VERSION(1,0) /* Watcom 11+ supports bool */ #define HAVE_BOOL #elif defined(__DIGITALMARS__) @@ -609,7 +609,7 @@ typedef int wxWindowID; #define except(x) catch(...) #endif /* Metrowerks */ -#if defined(__WATCOMC__) && (__WATCOMC__ < 1240) +#if wxONLY_WATCOM_EARLIER_THAN(1,4) typedef short mode_t; #endif @@ -1006,7 +1006,7 @@ inline void *wxUIntToPtr(wxUIntPtr p) #if defined(__PALMOS__) && !defined(HAVE_SSIZE_T) #define HAVE_SSIZE_T #endif -#if defined(__WATCOMC__) && __WATCOMC__ > 1230 +#if wxCHECK_WATCOM_VERSION(1,4) #define HAVE_SSIZE_T #endif #ifndef HAVE_SSIZE_T diff --git a/include/wx/filefn.h b/include/wx/filefn.h index 8f5f8adac0..d38c8ac285 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -278,13 +278,13 @@ enum wxFileKind // version of struct stat as well as a wide char stat function variant. // This was droped since OW 1.4 "for consistency across platforms". #if wxHAS_HUGE_FILES - #if wxUSE_UNICODE && defined(__WATCOMC__) && __WATCOMC__ < 1240 + #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) #define wxStructStat struct _wstati64 #else #define wxStructStat struct _stati64 #endif #else - #if wxUSE_UNICODE && defined(__WATCOMC__) && __WATCOMC__ < 1240 + #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) #define wxStructStat struct _wstat #else #define wxStructStat struct _stat diff --git a/include/wx/msw/chkconf.h b/include/wx/msw/chkconf.h index 53059846ab..2143e21124 100644 --- a/include/wx/msw/chkconf.h +++ b/include/wx/msw/chkconf.h @@ -37,7 +37,8 @@ #endif #ifndef wxUSE_NORLANDER_HEADERS -# if (defined(__WATCOMC__) && (__WATCOMC__ >= 1200)) || defined(__WINE__) || ((defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))) +# if ( wxCHECK_WATCOM_VERSION(1,0) || defined(__WINE__) ) || \ + ((defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))) # define wxUSE_NORLANDER_HEADERS 1 # else # define wxUSE_NORLANDER_HEADERS 0 @@ -167,12 +168,6 @@ # define wxUSE_DEBUG_NEW_ALWAYS 0 #endif -/* Early Watcom version don't have good enough wide char support */ -#if defined(__WXMSW__) && (defined(__WATCOMC__) && __WATCOMC__ < 1200) -# undef wxUSE_WCHAR_T -# define wxUSE_WCHAR_T 0 -#endif - /* DMC++ doesn't have definitions for date picker control, so use generic control */ #ifdef __DMC__ @@ -243,4 +238,3 @@ #endif /* wxUSE_DYNAMIC_LOADER */ #endif /* _WX_MSW_CHKCONF_H_ */ - diff --git a/include/wx/msw/gccpriv.h b/include/wx/msw/gccpriv.h index bb557b4cc0..b449670d94 100644 --- a/include/wx/msw/gccpriv.h +++ b/include/wx/msw/gccpriv.h @@ -32,7 +32,7 @@ #endif #endif -#if (defined(__WATCOMC__) && __WATCOMC__ >= 1200) +#if wxCHECK_WATCOM_VERSION(1,0) #define HAVE_W32API_H #endif diff --git a/include/wx/os2/private.h b/include/wx/os2/private.h index d5481d7add..d571467d30 100644 --- a/include/wx/os2/private.h +++ b/include/wx/os2/private.h @@ -24,8 +24,7 @@ #define INCL_WIN #include -#if defined(__WATCOMC__) && ( __WATCOMC__ < 1240 ) - // missing in OpenWatcom 1.3 but added in 1.4 +#if wxONLY_WATCOM_EARLIER_THAN(1,4) inline HATOMTBL APIENTRY WinQuerySystemAtomTable(VOID){return NULL;} inline ULONG APIENTRY WinQueryAtomName(HATOMTBL,ATOM,PCSZ,ULONG){return 0;} inline LONG APIENTRY GpiPointArc(HPS,PPOINTL){return GPI_ERROR;} diff --git a/include/wx/palmos/chkconf.h b/include/wx/palmos/chkconf.h index 121f45d407..d42eda8d5d 100644 --- a/include/wx/palmos/chkconf.h +++ b/include/wx/palmos/chkconf.h @@ -36,7 +36,7 @@ #endif #ifndef wxUSE_NORLANDER_HEADERS -#if (defined(__WATCOMC__) && (__WATCOMC__ >= 1200)) || defined(__WINE__) || ((defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))) +#if (defined(__WINE__) || ((defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))) # define wxUSE_NORLANDER_HEADERS 1 #else # define wxUSE_NORLANDER_HEADERS 0 @@ -106,4 +106,3 @@ #endif /* _WX_PALMOS_CHKCONF_H_ */ - diff --git a/include/wx/platform.h b/include/wx/platform.h index 50b2c69ce2..725e6a99cb 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -251,6 +251,21 @@ #endif +/* + This macro can be used to test the Open Watcom version. +*/ +#ifndef __WATCOMC__ +# define wxWATCOM_VERSION(major,minor) 0 +# define wxCHECK_WATCOM_VERSION(major,minor) 0 +# define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0 +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# error "Only Open Watcom is supported in this release" +#else +# define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 ) +# define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) ) +# define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) ) +#endif + /* check the consistency of the settings in setup.h: note that this must be done after setting wxUSE_UNICODE correctly as it is used in wx/chkconf.h @@ -446,7 +461,7 @@ # define __VISUALC__ _MSC_VER # elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__) # define __BORLANDC__ -# elif defined(__WATCOMC__) +# elif defined(__WATCOMC__) # elif defined(__SC__) # define __SYMANTECC__ # endif /* compiler */ @@ -517,7 +532,7 @@ */ #if ( defined( __GNUWIN32__ ) || defined( __MINGW32__ ) || \ ( defined( __CYGWIN__ ) && defined( __WINDOWS__ ) ) || \ - (defined(__WATCOMC__) && __WATCOMC__ >= 1200) ) && \ + wxCHECK_WATCOM_VERSION(1,0) ) && \ !defined(__DOS__) && \ !defined(__WXPM__) && \ !defined(__WXMOTIF__) && \ diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index ea432becaa..c4fe245958 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: filefn.cpp +// Name: src/common/filefn.cpp // Purpose: File- and directory-related functions // Author: Julian Smart // Modified by: @@ -1978,8 +1978,7 @@ wxFileKind wxGetFileKind(FILE *fp) { // Note: The watcom rtl dll doesn't have fileno (the static lib does). // Should be fixed in version 1.4. -#if defined(wxFILEKIND_STUB) || \ - (defined(__WATCOMC__) && __WATCOMC__ <= 1230 && defined(__SW_BR)) +#if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4) (void)fp; return wxFILE_KIND_DISK; #else diff --git a/src/common/imagjpeg.cpp b/src/common/imagjpeg.cpp index da980d2dd4..7e4dcedfba 100644 --- a/src/common/imagjpeg.cpp +++ b/src/common/imagjpeg.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: imagjpeg.cpp +// Name: src/common/imagjpeg.cpp // Purpose: wxImage JPEG handler // Author: Vaclav Slavik // RCS-ID: $Id$ @@ -29,7 +29,7 @@ // This causes a conflict with jmorecfg.h header from libjpeg, so we have // to make sure libjpeg won't try to define boolean itself. This is done by // defining HAVE_BOOLEAN. -#if defined(__WXMSW__) && (defined(__MWERKS__) || defined(__DIGITALMARS__) || (defined(__WATCOMC__) && __WATCOMC__ < 1200)) +#if defined(__WXMSW__) && (defined(__MWERKS__) || defined(__DIGITALMARS__)) #define HAVE_BOOLEAN #include "wx/msw/wrapwin.h" #endif @@ -420,9 +420,3 @@ bool wxJPEGHandler::DoCanRead( wxInputStream& stream ) #endif // wxUSE_STREAMS #endif // wxUSE_LIBJPEG - - - - - - diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index c277cf17b7..ca4e72c240 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -105,7 +105,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #if wxUSE_STREAMS #ifndef PNGLINKAGEMODE - #if defined(__WATCOMC__) && ( defined(__WXMSW__) || __WATCOMC__ > 1230 ) + #if defined(__WATCOMC__) && defined(__WXMSW__) // we need an explicit cdecl for Watcom, at least according to // // http://sf.net/tracker/index.php?func=detail&aid=651492&group_id=9863&atid=109863 diff --git a/src/common/textbuf.cpp b/src/common/textbuf.cpp index f7ca5e0818..2564a4cdbf 100644 --- a/src/common/textbuf.cpp +++ b/src/common/textbuf.cpp @@ -248,9 +248,7 @@ wxTextFileType wxTextBuffer::GuessType() const ? wxTextFileType_##t1 \ : wxTextFileType_##t2 - // Watcom C++ doesn't seem to be able to handle the macro - // VS: Watcom 11 doesn't have a problem... -#if !(defined(__WATCOMC__) && (__WATCOMC__ < 1100)) +#if !defined(__WATCOMC__) || wxCHECK_WATCOM_VERSION(1,4) if ( nDos > nUnix ) return GREATER_OF(Dos, Mac); else if ( nDos < nUnix ) -- 2.47.2