home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 14 / MA_Cover_14.iso / source / c / q1source_amy / qw / scitech / include / debug.h next >
Encoding:
C/C++ Source or Header  |  1997-03-04  |  7.2 KB  |  291 lines

  1. /****************************************************************************
  2. *
  3. *                   Copyright (C) 1996 SciTech Software
  4. *                           All rights reserved.
  5. *
  6. * Filename:     $Workfile:   debug.h  $
  7. * Version:      $Revision:   1.17  $
  8. *
  9. * Language:     ANSI C
  10. * Environment:  any
  11. *
  12. * Description:  General header file for operating system portable code.
  13. *
  14. * $Date:   04 Mar 1997 11:34:08  $ $Author:   KendallB  $
  15. *
  16. ****************************************************************************/
  17.  
  18. #ifndef __DEBUG_H
  19. #define __DEBUG_H
  20.  
  21. /* We have the following defines to identify the compilation environment:
  22.  *
  23.  *    __16BIT__        Compiling for 16 bit code (any environment)
  24.  *  __32BIT__       Compiling for 32 bit code (any environment)
  25.  *    __MSDOS__        Compiling for MS-DOS (includes __WINDOWS16__, __WIN386__)
  26.  *  __REALDOS__     Compiling for MS-DOS (excludes __WINDOWS16__)
  27.  *  __MSDOS16__     Compiling for 16 bit MS-DOS
  28.  *  __MSDOS32__     Compiling for 32 bit MS-DOS
  29.  *  __WINDOWS__     Compiling for Windows
  30.  *    __WINDOWS16__    Compiling for 16 bit Windows (__MSDOS__ also defined)
  31.  *    __WINDOWS32__    Compiling for 32 bit Windows
  32.  *  __WIN386__      Compiling for Watcom C++ Win386 extended Windows
  33.  *  __OS2__         Compiling for OS/2
  34.  *  __OS2_16__      Compiling for 16 bit OS/2
  35.  *  __OS2_32__         Compiling for 32 bit OS/2
  36.  *  __UNIX__           Compiling for Unix
  37.  *
  38.  */
  39.  
  40. #ifdef    __SC__
  41. #if        __INTSIZE == 4
  42. #define __SC386__
  43. #endif
  44. #endif
  45.  
  46. #ifdef    __GNUC__
  47. #define    __cdecl            /* GCC doesn't know about __cdecl modifiers        */
  48. #define    __FLAT__        /* GCC is always 32 bit flat model                */
  49. #define    __HAS_BOOL__    /* Latest GNU C++ has bool type                    */
  50. #endif
  51.  
  52. #ifdef    __BORLANDC__
  53. #if    (__BORLANDC__ >= 0x500) || defined(CLASSLIB_DEFS_H)
  54. #define    __HAS_BOOL__    /* Borland C++ 5.0 and later define bool type    */
  55. #endif
  56. #endif
  57.  
  58. /* For the Metaware High C/C++ compiler, there is no _cdecl calling
  59.  * convention. The conventions can be changed, but it is a complicated
  60.  * process involving #pragmas, and all externally referenced functions
  61.  * will use stack based calling conventions. We also need to change the
  62.  * global aliasing conventions to use underscores for external function
  63.  * and variables names, so that our assembler routines will link
  64.  * correctly (except of course the main function - man what a PAIN!).
  65.  */
  66.  
  67. #ifdef    __HIGHC__
  68. #define    __cdecl
  69. #define    __FLAT__    /* High C is always 32 bit flat model                */
  70. #pragma Global_aliasing_convention("_%r")
  71. extern main();
  72. #pragma Alias(main,"main")
  73. #endif
  74.  
  75. #if     defined(__MSDOS__) || defined(__DOS__) || defined(__DPMI32__) || (defined(M_I86) && !defined(__SC386__))
  76. #ifndef __MSDOS__
  77. #define __MSDOS__
  78. #endif
  79. #if     defined(__386__) || defined(__FLAT__) || defined(__NT__) || defined(__SC386__)
  80. #ifndef    __MSDOS32__
  81. #define __MSDOS32__
  82. #endif
  83. #ifndef    __32BIT__
  84. #define __32BIT__
  85. #endif
  86. #ifndef __REALDOS__
  87. #define __REALDOS__
  88. #endif
  89. #elif   (defined(_Windows) || defined(_WINDOWS)) && !defined(__DPMI16__)
  90. #ifndef    __16BIT__
  91. #define    __16BIT__
  92. #endif
  93. #ifndef __WINDOWS16__
  94. #define    __WINDOWS16__
  95. #endif
  96. #ifndef __WINDOWS__
  97. #define __WINDOWS__
  98. #endif
  99. #ifndef    __MSDOS__
  100. #define    __MSDOS__
  101. #endif
  102. #else
  103. #ifndef    __16BIT__
  104. #define    __16BIT__
  105. #endif
  106. #ifndef __MSDOS16__
  107. #define __MSDOS16__
  108. #endif
  109. #ifndef __REALDOS__
  110. #define __REALDOS__
  111. #endif
  112. #endif
  113. #elif   defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
  114. #ifndef    __32BIT__
  115. #define __32BIT__
  116. #endif
  117. #ifndef    __WINDOWS32__
  118. #define    __WINDOWS32__
  119. #endif
  120. #ifndef    _WIN32
  121. #define    _WIN32                    /* Microsoft Win32 SDK headers use _WIN32 */
  122. #endif
  123. #ifndef    WIN32
  124. #define    WIN32                    /* OpenGL headers use WIN32 */
  125. #endif
  126. #ifndef __WINDOWS__
  127. #define __WINDOWS__
  128. #endif
  129. #elif   defined(__WINDOWS_386__)
  130. #ifndef    __32BIT__
  131. #define __32BIT__
  132. #endif
  133. #ifndef __WIN386__
  134. #define __WIN386__
  135. #endif
  136. #ifndef __WINDOWS__
  137. #define __WINDOWS__
  138. #endif
  139. #ifndef    __MSDOS__
  140. #define    __MSDOS__
  141. #endif
  142. #elif   defined(__OS2__)
  143. #ifndef __OS2__                 /* TODO: to be completed */
  144. #define __OS2__
  145. #define    __OS2_32__                /* Default to 32 bit OS/2 */
  146. #endif
  147. #else
  148. #define __UNIX__                /* TODO: to be completed */
  149. #endif
  150.  
  151. /* We have the following defines to define the calling conventions for
  152.  * publicly accesible functions:
  153.  *
  154.  *  _PUBAPI - Compiler default calling conventions for all public 'C' functions
  155.  *  _ASMAPI - Calling conventions for all public assembler functions
  156.  *  _DLLAPI - Calling conventions for all DLL exported functions
  157.  *  _DLLVAR - Modifier to export/import globals in 32 bit DLL's
  158.  *  _EXPORT - Expands to _export when compiling a DLL
  159.  *  _VARAPI - Modifiers for variables; Watcom C++ mangles C++ globals
  160.  */
  161.  
  162. #define _PUBAPI    
  163. #define _ASMAPI __cdecl
  164.  
  165. #if defined(_MSC_VER) && defined(_WIN32) && !defined(__SC__)
  166. #define __PASCAL    __stdcall
  167. #define __export
  168. #define    __import
  169. #else
  170. #define __PASCAL    __pascal
  171. #endif
  172.  
  173. #if defined(__WATCOMC__)
  174. #define    _VARAPI        __cdecl
  175. #else
  176. #define    _VARAPI
  177. #endif
  178.  
  179. #if     defined(__WINDOWS__)
  180. #ifdef  BUILD_DLL
  181. #define _DLLASM __export __cdecl
  182. #define _EXPORT __export
  183. #ifdef  __WINDOWS32__
  184. #define _DLLAPI __export __PASCAL
  185. #define _DLLVAR __export
  186. #else
  187. #define _DLLAPI  __export __far __pascal
  188. #define _DLLVAR
  189. #endif
  190. #else
  191. #define _DLLASM __cdecl
  192. #define    _EXPORT
  193. #ifdef  __WINDOWS32__
  194. #define _DLLAPI __PASCAL
  195. #define _DLLVAR __import
  196. #else
  197. #define _DLLAPI __far __pascal
  198. #define _DLLVAR
  199. #endif
  200. #endif
  201. #else
  202. #define _EXPORT
  203. #define _DLLAPI
  204. #define _DLLVAR
  205. #endif
  206.  
  207. /* Useful macros */
  208.  
  209. #define PRIVATE static
  210. #define PUBLIC
  211.  
  212. #ifdef  DEBUG
  213. #       define DBG(x) x
  214. #else
  215. #       define DBG(x)
  216. #endif
  217.  
  218. #ifndef NULL
  219. #       define NULL 0L
  220. #endif
  221.  
  222. #ifndef MAX
  223. #       define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
  224. #endif
  225. #ifndef MIN
  226. #       define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
  227. #endif
  228. #ifndef ABS
  229. #       define ABS(a)   ((a) >= 0 ? (a) : -(a))
  230. #endif
  231. #ifndef    SIGN
  232. #        define SIGN(a)    ((a) > 0 ? 1 : -1)
  233. #endif
  234.  
  235. /* General typedefs */
  236.  
  237. #ifndef __GENDEFS
  238. #define __GENDEFS
  239. typedef unsigned char   uchar;
  240. typedef unsigned short  ushort;
  241. typedef unsigned int    uint;
  242. typedef unsigned long   ulong;
  243. typedef int             ibool;        /* Integer boolean type            */
  244. #ifndef    __cplusplus
  245. #define    bool            ibool        /* Standard C                    */
  246. #else
  247. #ifndef    __HAS_BOOL__
  248. #define    bool            ibool        /* Older C++ compilers            */
  249. #endif
  250. #endif    /* __cplusplus */
  251. #endif  /* __GENDEFS */
  252.  
  253. /* Includes Windows headers, as they define TRUE and FALSE */
  254.  
  255. #ifdef    __WINDOWS__
  256. #ifndef _WINDOWS_                   /* Dont include if already included */
  257. #ifndef __WIN386__
  258. #define STRICT
  259. #define    WIN32_LEAN_AND_MEAN
  260. #endif
  261. #include <windows.h>
  262. #endif
  263. #endif
  264.  
  265. /* Boolean truth values */
  266.  
  267. #undef    false
  268. #undef    true
  269. #undef    NO
  270. #undef    YES
  271. #undef    FALSE
  272. #undef    TRUE
  273.  
  274. #ifdef    __cplusplus                    /* Cast to bool's for C++ code        */
  275. #define false       ((bool)0)
  276. #define true        ((bool)1)
  277. #define NO          ((bool)0)
  278. #define YES         ((bool)1)
  279. #define FALSE       ((bool)0)
  280. #define TRUE        ((bool)1)
  281. #else                                /* Define to 0 and 1 for C code        */
  282. #define false       0
  283. #define true        1
  284. #define NO          0
  285. #define YES         1
  286. #define FALSE       0
  287. #define TRUE        1
  288. #endif
  289.  
  290. #endif  /* __DEBUG_H */
  291.