home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / sqdev200.zip / h / compiler.h < prev    next >
C/C++ Source or Header  |  1994-05-23  |  10KB  |  360 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *  Squish Developers Kit Source, Version 2.00                             *
  4.  *  Copyright 1989-1994 by SCI Communications.  All rights reserved.       *
  5.  *                                                                         *
  6.  *  USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE       *
  7.  *  SQUISH DEVELOPERS KIT LICENSING AGREEMENT IN SQDEV.PRN.  IF YOU DO NOT *
  8.  *  FIND THE TEXT OF THIS AGREEMENT IN THE AFOREMENTIONED FILE, OR IF YOU  *
  9.  *  DO NOT HAVE THIS FILE, YOU SHOULD IMMEDIATELY CONTACT THE AUTHOR AT    *
  10.  *  ONE OF THE ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO  *
  11.  *  USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE SQUISH          *
  12.  *  DEVELOPERS KIT LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE *
  13.  *  ABLE TO REACH WITH THE AUTHOR.                                         *
  14.  *                                                                         *
  15.  *  You can contact the author at one of the address listed below:         *
  16.  *                                                                         *
  17.  *  Scott Dudley       FidoNet     1:249/106                               *
  18.  *  777 Downing St.    Internet    sjd@f106.n249.z1.fidonet.org            *
  19.  *  Kingston, Ont.     CompuServe  >INTERNET:sjd@f106.n249.z1.fidonet.org  *
  20.  *  Canada  K7M 5N3    BBS         1-613-634-3058, V.32bis                 *
  21.  *                                                                         *
  22.  ***************************************************************************/
  23.  
  24. /*# name=Compiler-determination and memory-model-determination routines
  25.     name=Support for WATCOM C (DOS, OS/2 and 386 flat), Microsoft C
  26.     name=(all memory models, DOS & OS/2), Turbo C 2.0, Turbo/Borland C++
  27.     name=and IBM C Set/2 (flat model).
  28. */
  29.  
  30. /* Non-DOS systems...  Just do a "#define __FARCODE__",                     *
  31.  * "#define __FARDATA__" and "#define __LARGE__" in place of this file.     */
  32.  
  33. #ifndef __COMPILER_H_DEFINED
  34. #define __COMPILER_H_DEFINED
  35.  
  36.  
  37. #ifdef _lint  /* default to large segmented model when linting */
  38. #define __LARGE__
  39. #endif
  40.  
  41. /* Topaz - Borland C++ for OS/2 */
  42.  
  43. #if defined(__BORLANDC__) && defined(__OS2__)
  44.   #define __TOPAZ__  __BORLANDC__
  45.   #define __FLAT__
  46.   #define __386__
  47. #endif
  48.  
  49. #ifdef __GNUC__
  50.   #define __FLAT__
  51.   #define __386__
  52.   #define __POSIX__
  53. #endif
  54.  
  55. #ifdef __IBMC__ /* Set default library options for IBM's C Set/2 */
  56.   #define __FLAT__
  57.   #define __386__
  58. #endif
  59.  
  60. #if defined(NT) && !defined(__FLAT__)
  61.   #define __FLAT__
  62. #endif
  63.  
  64. /* WATCOM includes both M_I86xxx and __modeltype__ macros */
  65.  
  66. #ifndef __WATCOMC__
  67.  
  68.   #if (!defined(_lint) && (defined(M_I86SM) || defined(M_I86MM) || \
  69.                            defined(M_I86CM) || defined(M_I86LM) || \
  70.                            defined(M_I86HM) || defined(_MSC_VER)))
  71.     #define __MSC__
  72.   #endif
  73.  
  74.   #ifdef M_I86SM
  75.     #define __SMALL__
  76.   #endif
  77.  
  78.   #ifdef M_I86MM
  79.     #define __MEDIUM__
  80.   #endif
  81.  
  82.   #ifdef M_I86CM
  83.     #define __COMPACT__
  84.   #endif
  85.  
  86.   #ifdef M_I86LM
  87.     #define __LARGE__
  88.   #endif
  89.  
  90.   #ifdef M_I86HM
  91.     #define __HUGE__
  92.   #endif
  93.  
  94. #endif /* ! __WATCOMC__ */
  95.  
  96.  
  97.  
  98.  
  99. /* Handle 386 "flat" memory model, currently for IBM C Set/2 and WC386 */
  100.  
  101. #ifdef __FLAT__
  102.  
  103.   /* Other macros may get defined by braindead compilers */
  104.  
  105.   #ifdef __SMALL__
  106.     #undef __SMALL_
  107.   #endif
  108.  
  109.   #ifdef __TINY__
  110.     #undef __TINY__
  111.   #endif
  112.  
  113.   #ifdef __MEDIUM__
  114.     #undef __MEDIUM__
  115.   #endif
  116.  
  117.   #ifdef __COMPACT__
  118.     #undef __COMPACT__
  119.   #endif
  120.  
  121.   #ifdef __LARGE__
  122.     #undef __LARGE__
  123.   #endif
  124.  
  125.   #ifdef __HUGE__
  126.     #undef __HUGE__
  127.   #endif
  128.  
  129.   /* Code is really "near", but "far" in this context means that we want    *
  130.    * a 32 bit ptr (vice 16 bit).                                            */
  131.  
  132.   #define __FARCODE__
  133.   #define __FARDATA__
  134.  
  135.   /* Everything should be "near" in the flat model */
  136.  
  137.   #ifdef far
  138.     #undef far
  139.   #endif
  140.  
  141.   #ifdef near
  142.     #undef near
  143.   #endif
  144.  
  145.   #ifdef huge
  146.     #undef huge
  147.   #endif
  148.  
  149.   #define far
  150.   #define near
  151.   #define huge
  152.  
  153.  
  154.   /* Since we're using flat model OS/2, we never need to load DS */
  155.  
  156.   #ifdef OS_2
  157.     #ifdef _loadds
  158.       #undef _loadds
  159.     #endif
  160.  
  161.     #ifdef __loadds
  162.       #undef __loadds
  163.     #endif
  164.  
  165.     #define _loadds
  166.     #define __loadds
  167.   #endif
  168.  
  169. #else /* !FLAT */
  170.   #define __far16 far
  171. #endif
  172.  
  173.  
  174. /* Now handle the segmented memory models */
  175.  
  176. #if defined(__SMALL__) || defined(__TINY__)
  177.   #define __NEARCODE__
  178.   #define __NEARDATA__
  179. #endif
  180.  
  181. #ifdef __MEDIUM__
  182.   #define __FARCODE__
  183.   #define __NEARDATA__
  184. #endif
  185.  
  186. #ifdef __COMPACT__
  187.   #define __NEARCODE__
  188.   #define __FARDATA__
  189. #endif
  190.  
  191. #if defined(__LARGE__) || defined(__HUGE__)
  192.   #define __FARCODE__
  193.   #define __FARDATA__
  194. #endif
  195.  
  196.  
  197. /* Default to MS-DOS compile */
  198.  
  199. #if !defined(OS_2) && !defined(__MSDOS__) && !defined(NT) && !defined(UNIX)
  200.   #define __MSDOS__
  201. #endif
  202.  
  203.  
  204. /* Compiler-specific stuff:                                                 *
  205.  *                                                                          *
  206.  *  _stdc - Standard calling sequence.  This should be the type of          *
  207.  *          function required for function ptrs for qsort() et al.          *
  208.  *                                                                          *
  209.  *  _vstdc- Same as _stdc, but for variables.  In some compilers (WC, MSC), *
  210.  *          this determines whether or not a function has a leading         *
  211.  *          underscore.  Unfortunately, using _stdc is invalid when working *
  212.  *          with IBM C Set/2.                                               *
  213.  *                                                                          *
  214.  *  _fast - Fastest calling sequence supported.  If the default             *
  215.  *          calling sequence is the fastest, or if your compiler            *
  216.  *          only has one, define this to nothing.                           *
  217.  *                                                                          *
  218.  *  _intr - For defining interrupt functions.  For some idiotic             *
  219.  *          reason, MSC requires that interrupts be declared                *
  220.  *          as "cdecl interrupt", instead of just "interrupt".              */
  221.  
  222.  
  223. /****************************************************************************
  224.                       Turbo C 2.0, Turbo C++ and Borland C++
  225.  ****************************************************************************/
  226.  
  227. #if defined(__TURBOC__)
  228.  
  229.   #define _stdc     cdecl
  230.   #define _vstdc    cdecl
  231.   #define _intcast  void (_intr *)()
  232.   #define _veccast  _intcast
  233.  
  234.   #ifdef __TOPAZ__
  235.     #define _fast     __fastcall
  236.     #define _intr     __interrupt __far
  237.     #define _System   _syscall
  238.   #else
  239.     #define _fast     pascal
  240.     #define _intr     interrupt far
  241.   #endif
  242.  
  243.   #define _loadds
  244.  
  245.   #define NW(var) (void)var
  246.   /* structs are packed in TC by default, accd to TURBOC.CFG */
  247.  
  248. /****************************************************************************
  249.                              Microsoft C 6.0
  250.  ****************************************************************************/
  251.  
  252. #elif defined(__MSC__)
  253.  
  254.   #define _stdc     cdecl
  255.   #define _vstdc    cdecl
  256.   #define _intr     cdecl interrupt far
  257.   #define _intcast  void (_intr *)()
  258.   #define _veccast  _intcast
  259.  
  260.   #if _MSC_VER >= 600
  261.     #define _fast _fastcall
  262.   #else
  263.     #define _fast pascal
  264.   #endif
  265.  
  266.   #pragma pack(1)                 /* Structures should NOT be padded */
  267.   #define NW(var)  var = var      /* NW == No Warning */
  268.  
  269. /****************************************************************************
  270.                              WATCOM C 8.0/8.5
  271.  ****************************************************************************/
  272.  
  273. #elif defined(__WATCOMC__)
  274.  
  275.   #define _stdc
  276.   #define _vstdc
  277.   #define _intr     cdecl interrupt __far
  278.   #define _intcast  void (_intr *)()
  279.   #define _veccast  void (__interrupt __far *)()
  280.   #define _fast
  281.  
  282.   #pragma pack(1)                 /* Structures should NOT be padded */
  283.   #define NW(var)   (void)var
  284.  
  285.  
  286. /****************************************************************************
  287.                                 IBM C Set/2
  288.  ****************************************************************************/
  289.  
  290. #elif defined(__IBMC__)
  291.  
  292. #ifndef __MIG__
  293.   #define cdecl     /*_Cdecl*/
  294.   #define pascal    /*_Pascal*/
  295. #endif
  296.  
  297.   #define _stdc     /*_Optlink*/
  298.   #define _vstdc
  299.   #define _intr     /*_System*/
  300.   #define _intcast  void (_intr *)()
  301.   #define _veccast  void (_intr *)()
  302.   #define _fast
  303.  
  304.   #pragma pack(1)                 /* Structures should NOT be padded */
  305.   #define NW(var)   (void)var
  306.  
  307. /****************************************************************************
  308.                                 GNU C/C++
  309.  ****************************************************************************/
  310.  
  311. #elif defined(__GNUC__)
  312.   #define _stdc
  313.   #define _vstdc
  314.   #define _intr
  315.   #define _intcast
  316.   #define _veccast
  317.   #define _fast
  318.   #define _loadds
  319.  
  320.   #define pascal
  321.   #define cdecl
  322.   #define far
  323.   #define near
  324.  
  325.   #define NW(var) (void)var
  326.  
  327. /****************************************************************************
  328.                                     LINT
  329.  ****************************************************************************/
  330.  
  331. #elif defined(_lint)
  332.  
  333.   #define _stdc
  334.   #define _vstdc
  335.   #define _intr     cdecl interrupt __far
  336.   #define _intcast  void (_intr *)()
  337.   #define _veccast  void (__interrupt __far *)()
  338.   #define _fast
  339.  
  340.   #define NW(var)   (void)var
  341.  
  342. #else
  343.   #error Unknown compiler!
  344.  
  345.   #define _stdc
  346.   #define _intr     interrupt
  347.   #define _intcast  void (_intr *)()
  348.   #define _veccast  intr
  349.   #define _fast
  350.   #define NW(var)   (void)var
  351.   #define __MSDOS__
  352. #endif
  353.  
  354. #ifndef __TYPEDEFS_H_DEFINED
  355. #include "typedefs.h"
  356. #endif
  357.  
  358. #endif /* ! __COMPILER_H_DEFINED */
  359.  
  360.