defs.h

来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C头文件 代码 · 共 1,861 行 · 第 1/5 页

H
1,861
字号
/**
*  Name:        defs.h
*  Purpose:     Declarations/definitions common to all wx source files
*  Author:      Julian Smart and others
*  Modified by: Ryan Norton (Converted to C)
*  Created:     01/02/97
*  RCS-ID:      $Id: defs.h,v 1.513.2.4 2006/01/26 13:15:47 JS Exp $
*  Copyright:   (c) Julian Smart
*  Licence:     wxWindows licence
*/

/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */

#ifndef _WX_DEFS_H_
#define _WX_DEFS_H_

/*  ---------------------------------------------------------------------------- */
/*  compiler and OS identification */
/*  ---------------------------------------------------------------------------- */

#include "wx/platform.h"

#ifdef __cplusplus
/*  Make sure the environment is set correctly */
#   if defined(__WXMSW__) && defined(__X__)
#       error "Target can't be both X and Windows"
#   elif defined(__WXMSW__) && defined(__PALMOS__)
#       error "Target can't be both PalmOS and Windows"
#   elif !defined(__WXMOTIF__) && \
         !defined(__WXMSW__)   && \
         !defined(__WXPALMOS__)&& \
         !defined(__WXGTK__)   && \
         !defined(__WXPM__)    && \
         !defined(__WXMAC__)   && \
         !defined(__WXCOCOA__) && \
         !defined(__X__)       && \
         !defined(__WXMGL__)   && \
         !defined(__WXX11__)   && \
          wxUSE_GUI
#       ifdef __UNIX__
#           error "No Target! You should use wx-config program for compilation flags!"
#       else /*  !Unix */
#           error "No Target! You should use supplied makefiles for compilation!"
#       endif /*  Unix/!Unix */
#   endif
#endif /*__cplusplus*/

#ifndef __WXWINDOWS__
    #define __WXWINDOWS__ 1
#endif

#ifndef wxUSE_BASE
    /*  by default consider that this is a monolithic build */
    #define wxUSE_BASE 1
#endif

#if !wxUSE_GUI && !defined(__WXBASE__)
    #define __WXBASE__
#endif

/*  include the feature test macros */
#include "wx/features.h"

/*  suppress some Visual C++ warnings */
#ifdef __VISUALC__
    /*  the only "real" warning here is 4244 but there are just too many of them */
    /*  in our code... one day someone should go and fix them but until then... */
#   pragma warning(disable:4201)    /*  nonstandard extension used: nameless struct/union */
#   pragma warning(disable:4244)    /*  conversion from double to float */
#   pragma warning(disable:4710)    /*  function not inlined */
#   pragma warning(disable:4097)    /*  typedef used as class */
#   pragma warning(disable:4511)    /*  copy ctor couldn't be generated */
#   pragma warning(disable:4512)    /*  operator=() couldn't be generated */
#ifndef WIN32
#   pragma warning(disable:4135)    /*  conversion between different integral types */
#   pragma warning(disable:4769)    /*  assignment of near pointer to long integer */
/*  This one is really annoying, since it occurs for each cast to (HANDLE)... */
#   pragma warning(disable:4305)    /*  truncation of long to near ptr */
#endif

/* Deprecated functions such as sprintf, localtime */
#if __VISUALC__ >= 1400
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NON_CONFORMING_SWPRINTFS 1
#endif

#endif /*  __VISUALC__ */

/*  suppress some Salford C++ warnings */
#ifdef __SALFORDC__
#   pragma suppress 353             /*  Possible nested comments */
#   pragma suppress 593             /*  Define not used */
#   pragma suppress 61              /*  enum has no name (doesn't suppress!) */
#   pragma suppress 106             /*  unnamed, unused parameter */
#   pragma suppress 571             /*  Virtual function hiding */
#endif /*  __SALFORDC__ */

/*  suppress some Borland C++ warnings */
#ifdef __BORLANDC__
#   pragma warn -inl                /*  Functions containing reserved words and certain constructs are not expanded inline */
#endif /*  __BORLANDC__ */

/*  ---------------------------------------------------------------------------- */
/*  wxWidgets version and compatibility defines */
/*  ---------------------------------------------------------------------------- */

#include "wx/version.h"

/*  ============================================================================ */
/*  non portable C++ features */
/*  ============================================================================ */

/*  ---------------------------------------------------------------------------- */
/*  compiler defects workarounds */
/*  ---------------------------------------------------------------------------- */

/*
   Digital Unix C++ compiler only defines this symbol for .cxx and .hxx files,
   so define it ourselves (newer versions do it for all files, though, and
   don't allow it to be redefined)
 */
#if defined(__DECCXX) && !defined(__VMS) && !defined(__cplusplus)
#define __cplusplus
#endif /* __DECCXX */

/*  Resolves linking problems under HP-UX when compiling with gcc/g++ */
#if defined(__HPUX__) && defined(__GNUG__)
#define va_list __gnuc_va_list
#endif /*  HP-UX */

/*  ---------------------------------------------------------------------------- */
/*  check for native bool type and TRUE/FALSE constants */
/*  ---------------------------------------------------------------------------- */

/*  Add more tests here for Windows compilers that already define bool */
/*  (under Unix, configure tests for this) */
#ifndef HAVE_BOOL
    #if defined( __MWERKS__ )
        #if (__MWERKS__ >= 0x1000) && __option(bool)
            #define HAVE_BOOL
        #endif
    #elif defined(__APPLE__) && defined(__APPLE_CC__)
        /*  Apple bundled gcc supports bool */
        #define HAVE_BOOL
    #elif defined(__VISUALC__) && (__VISUALC__ == 1020)
        /*  in VC++ 4.2 the bool keyword is reserved (hence can't be typedefed) */
        /*  but not implemented, so we must #define it */
        #define bool unsigned int
    #elif defined(__VISUALC__) && (__VISUALC__ == 1010)
        /*  For VisualC++ 4.1, we need to define */
        /*  bool as something between 4.0 & 5.0... */
        typedef unsigned int wxbool;
        #define bool wxbool
        #define HAVE_BOOL
    #elif defined(__VISUALC__) && (__VISUALC__ > 1020)
        /*  VC++ supports bool since 4.2 */
        #define HAVE_BOOL
    #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x500)
        /*  Borland 5.0+ supports bool */
        #define HAVE_BOOL
    #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
        /*  Watcom 11+ supports bool */
        #define HAVE_BOOL
    #elif defined(__DIGITALMARS__)
        /*  DigitalMars supports bool */
        #define HAVE_BOOL
    #elif defined(__GNUWIN32__) || defined(__MINGW32__) || defined(__CYGWIN__)
        /*  Cygwin supports bool */
        #define HAVE_BOOL
    #elif defined(__VISAGECPP__)
        #if __IBMCPP__ < 400
            typedef unsigned long bool;
            #define true ((bool)1)
            #define false ((bool)0)
        #endif
        #define HAVE_BOOL
    #endif /*  compilers */
#endif /*  HAVE_BOOL */

#if !defined(__MWERKS__) || !defined(true)
#if !defined(HAVE_BOOL) && !defined(bool) && !defined(VMS)
    /*  NB: of course, this doesn't replace the standard type, because, for */
    /*      example, overloading based on bool/int parameter doesn't work and */
    /*      so should be avoided in portable programs */
    typedef unsigned int bool;
#endif /*  bool */

/*  deal with TRUE/true stuff: we assume that if the compiler supports bool, it */
/*  supports true/false as well and that, OTOH, if it does _not_ support bool, */
/*  it doesn't support these keywords (this is less sure, in particular VC++ */
/*  4.x could be a problem here) */
#ifndef HAVE_BOOL
    #define true ((bool)1)
    #define false ((bool)0)
#endif
#endif

/*  for backwards compatibility, also define TRUE and FALSE */
/*  */
/*  note that these definitions should work both in C++ and C code, so don't */
/*  use true/false below */
#ifndef TRUE
    #define TRUE 1
#endif

#ifndef FALSE
    #define FALSE 0
#endif

typedef short int WXTYPE;

/*  special care should be taken with this type under Windows where the real */
/*  window id is unsigned, so we must always do the cast before comparing them */
/*  (or else they would be always different!). Using wxGetWindowId() which does */
/*  the cast itself is recommended. Note that this type can't be unsigned */
/*  because wxID_ANY == -1 is a valid (and largely used) value for window id. */
typedef int wxWindowID;

/*  ---------------------------------------------------------------------------- */
/*  other feature tests */
/*  ---------------------------------------------------------------------------- */

/*  Every ride down a slippery slope begins with a single step.. */
/*  */
/*  Yes, using nested classes is indeed against our coding standards in */
/*  general, but there are places where you can use them to advantage */
/*  without totally breaking ports that cannot use them.  If you do, then */
/*  wrap it in this guard, but such cases should still be relatively rare. */
#define wxUSE_NESTED_CLASSES    1

/*  check for explicit keyword support */
#ifndef HAVE_EXPLICIT
    #if defined(__VISUALC__) && (__VISUALC__ >= 1100)
        /*  VC++ 6.0 and 5.0 have explicit (what about earlier versions?) */
        #define HAVE_EXPLICIT
    #elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \
          && wxCHECK_GCC_VERSION(2, 95)
        /*  GCC 2.95 has explicit, what about earlier versions? */
        #define HAVE_EXPLICIT
    #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)
        /*  BC++ 4.52 doesn't support explicit, CBuilder 1 does */
        #define HAVE_EXPLICIT
    #elif defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
        /*  Metrowerks CW6 or higher has explicit */
        #define HAVE_EXPLICIT
    #elif defined(__DIGITALMARS__)
        #define HAVE_EXPLICIT
    #endif
#endif /*  !HAVE_EXPLICIT */

#ifdef HAVE_EXPLICIT
    #define wxEXPLICIT explicit
#else /*  !HAVE_EXPLICIT */
    #define wxEXPLICIT
#endif /*  HAVE_EXPLICIT/!HAVE_EXPLICIT */

/* check for static/const_cast<>() (we don't use the other ones for now) */
#ifndef HAVE_CXX_CASTS
    #if defined(__VISUALC__) && (__VISUALC__ >= 1100)
        /*  VC++ 6.0 and 5.0 have C++ casts (what about earlier versions?) */
        #define HAVE_CXX_CASTS
    #elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \
          && wxCHECK_GCC_VERSION(2, 95)
        /*  GCC 2.95 has C++ casts, what about earlier versions? */
        #define HAVE_CXX_CASTS
    #endif
#endif /*  !HAVE_CXX_CASTS */

#ifdef HAVE_CXX_CASTS
    #ifndef HAVE_CONST_CAST
        #define HAVE_CONST_CAST
    #endif
    #ifndef HAVE_REINTERPRET_CAST
        #define HAVE_REINTERPRET_CAST
    #endif
    #ifndef HAVE_STATIC_CAST
        #define HAVE_STATIC_CAST
    #endif
    #ifndef HAVE_DYNAMIC_CAST
        #define HAVE_DYNAMIC_CAST
    #endif
#endif /*  HAVE_CXX_CASTS */

#ifdef HAVE_STATIC_CAST
    #define wx_static_cast(t, x) static_cast<t>(x)
#else
    #define wx_static_cast(t, x) ((t)(x))
#endif

#ifdef HAVE_CONST_CAST
    #define wx_const_cast(t, x) const_cast<t>(x)
#else
    #define wx_const_cast(t, x) ((t)(x))
#endif

#ifdef HAVE_REINTERPRET_CAST
    #define wx_reinterpret_cast(t, x) reinterpret_cast<t>(x)
#else
    #define wx_reinterpret_cast(t, x) ((t)(x))
#endif

/*
   This one is a wx invention: like static cast but used when we intentionally
   truncate from a larger to smaller type, static_cast<> can't be used for it
   as it results in warnings when using some compilers (SGI mipspro for example)
 */
#if defined(__cplusplus) && wxABI_VERSION >= 20603
    #if defined(__INTELC__)
        template <typename T, typename X>
        inline T wx_truncate_cast_impl(X x)
        {
            #pragma warning(push)
            /* implicit conversion of a 64-bit integral type to a smaller integral type */
            #pragma warning(disable: 1682)
            /* conversion from "X" to "T" may lose significant bits */
            #pragma warning(disable: 810)

            return x;

            #pragma warning(pop)
        }

        #define wx_truncate_cast(t, x) wx_truncate_cast_impl<t>(x)

    #elif defined(__VISUALC__) && __VISUALC__ >= 1310
        template <typename T, typename X>
        inline T wx_truncate_cast_impl(X x)
        {
            #pragma warning(push)
            /* conversion from 'X' to 'T', possible loss of data */
            #pragma warning(disable: 4267)

            return x;

            #pragma warning(pop)
        }

        #define wx_truncate_cast(t, x) wx_truncate_cast_impl<t>(x)
    #else
        #define wx_truncate_cast(t, x) ((t)(x))
    #endif
#else  /* defined(__cplusplus) && wxABI_VERSION >= 20603 */
    #define wx_truncate_cast(t, x) ((t)(x))
#endif /* defined(__cplusplus) && wxABI_VERSION >= 20603 */

/* for consistency with wxStatic/DynamicCast defined in wx/object.h */
#define wxConstCast(obj, className) wx_const_cast(className *, obj)

#ifndef HAVE_STD_WSTRING
    #if defined(__VISUALC__) && (__VISUALC__ >= 1100)
        /*  VC++ 6.0 and 5.0 have std::wstring (what about earlier versions?) */
        #define HAVE_STD_WSTRING
    #elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \
          && wxCHECK_GCC_VERSION(3, 1)
        /*  GCC 3.1 has std::wstring; 3.0 never was in MinGW, 2.95 hasn't it */
        #define HAVE_STD_WSTRING
    #endif
#endif

#ifndef HAVE_STD_STRING_COMPARE
    #if defined(__VISUALC__) && (__VISUALC__ >= 1100)
        /*  VC++ 6.0 and 5.0 have std::string::compare */
        /*  (what about earlier versions?) */
        #define HAVE_STD_STRING_COMPARE
    #elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \
          && wxCHECK_GCC_VERSION(3, 1)
        /*  GCC 3.1 has std::string::compare; */
        /*  3.0 never was in MinGW, 2.95 hasn't it */
        #define HAVE_STD_STRING_COMPARE
    #endif
#endif

/* provide replacement for C99 va_copy() if the compiler doesn't have it */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?