defs.h

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

H
1,861
字号

/* could be already defined by configure or the user */
#ifndef wxVaCopy
    /* if va_copy is a macro or configure detected that we have it, use it */
    #if defined(va_copy) || defined(HAVE_VA_COPY)
        #define wxVaCopy va_copy
    #else /* no va_copy, try to provide a replacement */
        /*
           configure tries to determine whether va_list is an array or struct
           type, but it may not be used under Windows, so deal with a few
           special cases.
         */

        #ifdef __WATCOMC__
            /* Watcom uses array type for va_list except for PPC and Alpha */
            #if !defined(__PPC__) && !defined(__AXP__)
                #define VA_LIST_IS_ARRAY
            #endif
        #endif /* __WATCOMC__ */

        #if defined(__PPC__) && (defined(_CALL_SYSV) || defined (_WIN32))
            /*
                PPC using SysV ABI and NT/PPC are special in that they use an
                extra level of indirection.
             */
            #define VA_LIST_IS_POINTER
        #endif /* SysV or Win32 on __PPC__ */

        /*
            note that we use memmove(), not memcpy(), in case anybody tries
            to do wxVaCopy(ap, ap)
         */
        #if defined(VA_LIST_IS_POINTER)
            #define wxVaCopy(d, s)  memmove(*(d), *(s), sizeof(va_list))
        #elif defined(VA_LIST_IS_ARRAY)
            #define wxVaCopy(d, s) memmove((d), (s), sizeof(va_list))
        #else /* we can only hope that va_lists are simple lvalues */
            #define wxVaCopy(d, s) ((d) = (s))
        #endif
    #endif /* va_copy/!va_copy */
#endif /* wxVaCopy */


/*  ---------------------------------------------------------------------------- */
/*  portable calling conventions macros */
/*  ---------------------------------------------------------------------------- */

/*  stdcall is used for all functions called by Windows under Windows */
#if defined(__WINDOWS__)
    #if defined(__GNUWIN32__)
        #define wxSTDCALL __attribute__((stdcall))
    #else
        /*  both VC++ and Borland understand this */
        #define wxSTDCALL _stdcall
    #endif

#else /*  Win */
    /*  no such stupidness under Unix */
    #define wxSTDCALL
#endif /*  platform */

/*  LINKAGEMODE mode is empty for everyting except OS/2 */
#ifndef LINKAGEMODE
    #define LINKAGEMODE
#endif /*  LINKAGEMODE */

/*  wxCALLBACK should be used for the functions which are called back by */
/*  Windows (such as compare function for wxListCtrl) */
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
    #define wxCALLBACK wxSTDCALL
#else
    /*  no stdcall under Unix nor Win16 */
    #define wxCALLBACK
#endif /*  platform */

/*  generic calling convention for the extern "C" functions */

#if defined(__VISUALC__)
  #define   wxC_CALLING_CONV    _cdecl
#elif defined(__VISAGECPP__)
  #define   wxC_CALLING_CONV    _Optlink
#else   /*  !Visual C++ */
  #define   wxC_CALLING_CONV
#endif  /*  compiler */

/*  callling convention for the qsort(3) callback */
#define wxCMPFUNC_CONV wxC_CALLING_CONV

/*  compatibility :-( */
#define CMPFUNC_CONV wxCMPFUNC_CONV

/*  DLL import/export declarations */
#include "wx/dlimpexp.h"

/*  ---------------------------------------------------------------------------- */
/*  Very common macros */
/*  ---------------------------------------------------------------------------- */

/*  Printf-like attribute definitions to obtain warnings with GNU C/C++ */
#if defined(__GNUC__) && !wxUSE_UNICODE
#  ifndef ATTRIBUTE_PRINTF
#    define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
#    define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
#    define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
#    define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
#    define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
#    define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
#  endif /* ATTRIBUTE_PRINTF */
#else
#  ifndef ATTRIBUTE_PRINTF
#    define ATTRIBUTE_PRINTF
#    define ATTRIBUTE_PRINTF_1
#    define ATTRIBUTE_PRINTF_2
#    define ATTRIBUTE_PRINTF_3
#    define ATTRIBUTE_PRINTF_4
#    define ATTRIBUTE_PRINTF_5
#  endif /* ATTRIBUTE_PRINTF */
#endif

/*  Macro to issue warning when using deprecated functions with gcc3 or MSVC7: */
#if wxCHECK_GCC_VERSION(3, 1)
    #define wxDEPRECATED(x) x __attribute__ ((deprecated))
#elif defined(__VISUALC__) && (__VISUALC__ >= 1300)
    #define wxDEPRECATED(x) __declspec(deprecated) x
#else
    #define wxDEPRECATED(x) x
#endif

/*  everybody gets the assert and other debug macros */
#include "wx/debug.h"

/*  NULL declaration: it must be defined as 0 for C++ programs (in particular, */
/*  it must not be defined as "(void *)0" which is standard for C but completely */
/*  breaks C++ code) */
#ifndef __HANDHELDPC__
#include <stddef.h>
#endif

/*  delete pointer if it is not NULL and NULL it afterwards */
/*  (checking that it's !NULL before passing it to delete is just a */
/*   a question of style, because delete will do it itself anyhow, but it might */
/*   be considered as an error by some overzealous debugging implementations of */
/*   the library, so we do it ourselves) */
#define wxDELETE(p)      if ( (p) != NULL ) { delete p; p = NULL; }

/*  delete an array and NULL it (see comments above) */
#define wxDELETEA(p)     if ( (p) ) { delete [] (p); p = NULL; }

/*  size of statically declared array */
#define WXSIZEOF(array)   (sizeof(array)/sizeof(array[0]))

/*  helper macros to concatenate two tokens together */
#define wxCONCAT_HELPER(text, line) text ## line
#define wxCONCAT(text, line)        wxCONCAT_HELPER(text, line)

/*  helper macros to be able to define unique/anonymous objects: this works by */
/*  appending the current line number to the given identifier to reduce the */
/*  probability of the conflict (it may still happen if this is used in the */
/*  headers, hence you should avoid doing it or provide unique prefixes then) */
#if defined(__VISUALC__) && (__VISUALC__ >= 1300)
    /*
       __LINE__ handling is completely broken in VC++ when using "Edit and
       Continue" (/ZI option) and results in preprocessor errors if we use it
       inside the macros. Luckily VC7 has another standard macro which can be
       used like this and is even better than __LINE__ because it is globally
       unique.
     */
#   define wxCONCAT_LINE(text)         wxCONCAT(text, __COUNTER__)
#else /* normal compilers */
#   define wxCONCAT_LINE(text)         wxCONCAT(text, __LINE__)
#endif
#define wxMAKE_UNIQUE_NAME(text)    wxCONCAT_LINE(text)

/*  symbolic constant used by all Find()-like functions returning positive */
/*  integer on success as failure indicator */
#define wxNOT_FOUND       (-1)

/*  ---------------------------------------------------------------------------- */
/*  macros to avoid compiler warnings */
/*  ---------------------------------------------------------------------------- */

/*  Macro to cut down on compiler warnings. */
#if 1 /*  there should be no more any compilers needing the "#else" version */
    #define WXUNUSED(identifier) /* identifier */
#else  /*  stupid, broken compiler */
    #define WXUNUSED(identifier) identifier
#endif

/*  some arguments are only used in debug mode, but unused in release one */
#ifdef __WXDEBUG__
    #define WXUNUSED_UNLESS_DEBUG(param)  param
#else
    #define WXUNUSED_UNLESS_DEBUG(param)  WXUNUSED(param)
#endif

/*  some arguments are not used in unicode mode */
#if wxUSE_UNICODE
    #define WXUNUSED_IN_UNICODE(param)  WXUNUSED(param)
#else
    #define WXUNUSED_IN_UNICODE(param)  param
#endif

/*  some arguments are not used in WinCE build */
#ifdef __WXWINCE__
    #define WXUNUSED_IN_WINCE(param)  WXUNUSED(param)
#else
    #define WXUNUSED_IN_WINCE(param)  param
#endif

/*  some compilers give warning about a possibly unused variable if it is */
/*  initialized in both branches of if/else and shut up if it is initialized */
/*  when declared, but other compilers then give warnings about unused variable */
/*  value -- this should satisfy both of them */
#if defined(__VISUALC__)
    #define wxDUMMY_INITIALIZE(val) = val
#else
    #define wxDUMMY_INITIALIZE(val)
#endif

/*  sometimes the value of a variable is *really* not used, to suppress  the */
/*  resulting warning you may pass it to this function */
#ifdef __cplusplus
#   ifdef __BORLANDC__
#       define wxUnusedVar(identifier) identifier
#   else
        template <class T>
            inline void wxUnusedVar(const T& WXUNUSED(t)) { }
#   endif
#endif

/*  ---------------------------------------------------------------------------- */
/*  compiler specific settings */
/*  ---------------------------------------------------------------------------- */

/*  to allow compiling with warning level 4 under Microsoft Visual C++ some */
/*  warnings just must be disabled */
#ifdef  __VISUALC__
  #pragma warning(disable: 4514) /*  unreferenced inline func has been removed */
/*
  you might be tempted to disable this one also: triggered by CHECK and FAIL
  macros in debug.h, but it's, overall, a rather useful one, so I leave it and
  will try to find some way to disable this warning just for CHECK/FAIL. Anyone?
*/
  #pragma warning(disable: 4127) /*  conditional expression is constant */
#endif  /*  VC++ */

#if defined(__MWERKS__)
    #undef try
    #undef except
    #undef finally
    #define except(x) catch(...)
#endif /*  Metrowerks */

#if wxONLY_WATCOM_EARLIER_THAN(1,4)
    typedef short mode_t;
#endif

/*  where should i put this? we need to make sure of this as it breaks */
/*  the <iostream> code. */
#if !wxUSE_IOSTREAMH && defined(__WXDEBUG__)
#  ifndef __MWERKS__
/*  #undef __WXDEBUG__ */
#    ifdef wxUSE_DEBUG_NEW_ALWAYS
#    undef wxUSE_DEBUG_NEW_ALWAYS
#    define wxUSE_DEBUG_NEW_ALWAYS 0
#    endif
#  endif
#endif

/*  ---------------------------------------------------------------------------- */
/*  OS mnemonics -- Identify the running OS (useful for Windows) */
/*  ---------------------------------------------------------------------------- */

/*  Not all platforms are currently available or supported */
enum
{
    wxUNKNOWN_PLATFORM,
    wxCURSES,                 /*  Text-only CURSES */
    wxXVIEW_X,                /*  Sun's XView OpenLOOK toolkit */
    wxMOTIF_X,                /*  OSF Motif 1.x.x */
    wxCOSE_X,                 /*  OSF Common Desktop Environment */
    wxNEXTSTEP,               /*  NeXTStep */
    wxMAC,                    /*  Apple Mac OS 8/9/X with Mac paths */
    wxMAC_DARWIN,             /*  Apple Mac OS X with Unix paths */
    wxBEOS,                   /*  BeOS */
    wxGTK,                    /*  GTK on X */
    wxGTK_WIN32,              /*  GTK on Win32 */
    wxGTK_OS2,                /*  GTK on OS/2 */
    wxGTK_BEOS,               /*  GTK on BeOS */
    wxGEOS,                   /*  GEOS */
    wxOS2_PM,                 /*  OS/2 Workplace */
    wxWINDOWS,                /*  Windows or WfW */
    wxMICROWINDOWS,           /*  MicroWindows */
    wxPENWINDOWS,             /*  Windows for Pen Computing */
    wxWINDOWS_NT,             /*  Windows NT */
    wxWIN32S,                 /*  Windows 32S API */
    wxWIN95,                  /*  Windows 95 */
    wxWIN386,                 /*  Watcom 32-bit supervisor modus */
    wxWINDOWS_CE,             /*  Windows CE (generic) */
    wxWINDOWS_POCKETPC,       /*  Windows CE PocketPC */
    wxWINDOWS_SMARTPHONE,     /*  Windows CE Smartphone */
    wxMGL_UNIX,               /*  MGL with direct hardware access */
    wxMGL_X,                  /*  MGL on X */
    wxMGL_WIN32,              /*  MGL on Win32 */
    wxMGL_OS2,                /*  MGL on OS/2 */
    wxMGL_DOS,                /*  MGL on MS-DOS */
    wxWINDOWS_OS2,            /*  Native OS/2 PM */
    wxUNIX,                   /*  wxBase under Unix */
    wxX11,                    /*  Plain X11 and Universal widgets */
    wxPALMOS,                 /*  PalmOS */
    wxDOS                     /*  wxBase under MS-DOS */
};

/*  ---------------------------------------------------------------------------- */
/*  standard wxWidgets types */
/*  ---------------------------------------------------------------------------- */

/*  the type for screen and DC coordinates */
typedef int wxCoord;

enum {  wxDefaultCoord = -1 };

/*  ---------------------------------------------------------------------------- */
/*  define fixed length types */
/*  ---------------------------------------------------------------------------- */

#if defined(__WXPALMOS__) || defined(__MINGW32__)
    #include <sys/types.h>
#endif

/*  chars are always one byte (by definition), shorts are always two (in */
/*  practice) */

/*  8bit */
#ifndef SIZEOF_CHAR
    #define SIZEOF_CHAR 1
#endif
typedef signed char wxInt8;
typedef unsigned char wxUint8;
typedef wxUint8 wxByte;


/*  16bit */
#ifdef SIZEOF_SHORT
    #if SIZEOF_SHORT != 2
        #error "wxWidgets assumes sizeof(short) == 2, please fix the code"
    #endif
#else
    #define SIZEOF_SHORT 2
#endif

typedef signed short wxInt16;
typedef unsigned short wxUint16;

typedef wxUint16 wxWord;

/*
  things are getting more interesting with ints, longs and pointers

  there are several different standard data models described by this table:

  +-----------+----------------------------+
  |type\model | LP64 ILP64 LLP64 ILP32 LP32|
  +-----------+----------------------------+
  |char       |  8     8     8     8     8 |
  |short      | 16    16    16    16    16 |
  |int        | 32    64    32    32    16 |
  |long       | 64    64    32    32    32 |
  |long long  |             64             |
  |void *     | 64    64    64    32    32 |
  +-----------+----------------------------+

  Win16 used LP32 (but we don't support it any longer), Win32 obviously used

⌨️ 快捷键说明

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