#if !defined(__STDDEFS__)
#define __STDDEFS__

#ifdef RC_INVOKED
#else // RC_INVOKED
#ifdef WIN32
#pragma warning (disable:4200)
#endif // WIN32

#if 0 // def _DEBUG
inline void HEAPCHK()
{
  PVOID pa[10];
  int i;
  for(i = 0; i < 10; i++) {
    pa[i] = malloc(rand() % 32000 + 767);
    ASSERT(_heapchk() == _HEAPOK);
  }
  _HEAPINFO hh;
  int nRet;
  hh._pentry = NULL;
  while((nRet = _heapwalk(&hh)) == _HEAPOK)
      ;
  if (nRet != _HEAPEND) {
    ASSERT(FALSE);
  }
  for(i = 0; i < 10; i++) {
    free(pa[i]);
    ASSERT(_heapchk() == _HEAPOK);
  }
}
#else
#define HEAPCHK()
#endif

#ifdef WIN32
#pragma pack(push, 1)
#endif // WIN32

union WORDPACK {
    struct {
    BYTE m_bLow;
    BYTE m_bHigh;
    } m_W;
    WORD m_wValue;
};
typedef WORDPACK*                   PWORDPACK;

union DWORDPACK {
    struct {
    WORDPACK m_wLow;
    WORDPACK m_wHigh;
    } m_DW;
    DWORD m_dwValue;
};
typedef DWORDPACK*                  PDWORDPACK;

#ifdef WIN32
#pragma pack(pop)
#endif // WIN32

#define GETLBYTE(W)                 (((PWORDPACK)&(W))->m_W.m_bLow)
#define GETHBYTE(W)                 (((PWORDPACK)&(W))->m_W.m_bHigh)
#define GETLWORD(D)                 (((PDWORDPACK)&(D))->m_DW.m_wLow.m_wValue)
#define GETHWORD(D)                 (((PDWORDPACK)&(D))->m_DW.m_wHigh.m_wValue)

#define WORDHI(lvalue)              (*((LPWORD)&(lvalue) + 1))
#define BYTEHI(lvalue)              (*((LPBYTE)&(lvalue) + 1))
#define MAKE_VERSION(rmj, rmm, rup) (((DWORD)rmj) << 16) | (((DWORD)rmm) << 8) | (((DWORD)rup) << 0)

#define NOFA(name_of_array)         (sizeof(name_of_array)/sizeof(name_of_array[0]))

#define ChkFlag(flag,mask)          ((flag)  &  (mask))
#define SetFlag(flag,mask)          ((flag) |=  (mask))
#define XorFlag(flag,mask)          ((flag) ^=  (mask))
#define ClrFlag(flag,mask)          ((flag) &= ~(mask))

#ifdef _DEBUG
#define DEBUGONLY(expr)             (expr)
#else
#define DEBUGONLY(expr)
#endif

typedef signed long                 SINT; // logical unit, signed 32bit
typedef short                       SINT16;
typedef unsigned short              UINT16;
typedef int                         SINT32;
#if _MSC_VER <= 1100
typedef unsigned int                UINT32;
#endif // _MSC_VER <== 1100(developers studio 5.0)
#ifdef WIN32
typedef __int64                     SINT64;
typedef unsigned __int64            UINT64;
#else // WIN32
typedef long long                   SINT64;
typedef unsigned long long          UINT64;
#endif // WIN32
typedef float                       FLOAT;
typedef double                      DOUBLE;

typedef	unsigned char	            U8;
typedef signed char		            S8;
typedef unsigned short	            U16;
typedef signed short	            S16;
typedef unsigned int	            U32;
typedef signed int		            S32;

#define SIZE_SINT                   4
#define SIZE_SINT16                 2
#define SIZE_UINT16                 2
#define SIZE_SINT32                 4
#define SIZE_UINT32                 4
#define SIZE_SINT64                 8
#define SIZE_UINT64                 8
#define SIZE_FLOAT                  4
#define SIZE_DOUBLE                 8

typedef SINT*                       PSINT;
typedef PSINT*                      PPSINT;
typedef SINT16*                     PSINT16;
typedef PSINT16*                    PPSINT16;
typedef UINT16*                     PUINT16;
typedef PUINT16*                    PPUINT16;
typedef SINT32*                     PSINT32;
typedef PSINT32*                    PPSINT32;
typedef UINT32*                     PUINT32;
typedef PUINT32*                    PPUINT32;
typedef SINT64*                     PSINT64;
typedef PSINT64*                    PPSINT64;
typedef UINT64*                     PUINT64;
typedef PUINT64*                    PPUINT64;
typedef FLOAT*                      PFLOAT;
typedef PFLOAT*                     PPFLOAT;
typedef DOUBLE*                     PDOUBLE;
typedef PDOUBLE*                    PPDOUBLE;

#if !(defined(BOOL) || defined(TRUE) || defined(FALSE))
#define BOOL                        int
#define TRUE                        1
#define FALSE                       0
#endif

#if 1 // def WIN32
#define DECLARE_VOIDHANDLE(name)    struct __##name##__ { int unused; };  typedef const struct __##name##__* name

#define DECLARE_CLASS(name)         __DECLARE_CLASS(C,name)
#define DECLARE_CLASS_PTR(name)     __DECLARE_CLASS_PTR(C,name)
#define __DECLARE_CLASS(prefix,name) class prefix##name; typedef class prefix##name* P##name; typedef const class prefix##name* PC##name
#define __DECLARE_CLASS_PTR(prefix,name) __DECLARE_CLASS(prefix, name); typedef P##name* PP##name; typedef PC##name* PPC##name

#define DECLARE_STRUCT(name)        __DECLARE_STRUCT(S,name)
#define DECLARE_STRUCT_PTR(name)    __DECLARE_STRUCT_PTR(S,name)
#define __DECLARE_STRUCT(prefix,name) struct prefix##name; typedef struct prefix##name* P##name; typedef const struct prefix##name* PC##name;
#define __DECLARE_STRUCT_PTR(prefix,name) __DECLARE_STRUCT(prefix,name); typedef P##name* PP##name; typedef PC##name* PPC##name
#endif // WIN32

#define DLLDAT // will be redefined, if necessary in dllapi.h
#define DLLAPI // will be redefined, if necessary in dllapi.h
#define DLLCLS // will be redefined, if necessary in dllapi.h

#endif // RC_INVOKED

#endif // __STDDEFS__
