Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - in addition to the standard ansi/iso-defined macros supported by the watcom http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
In addition to the standard ANSI/ISO-defined macros supported by the Watcom
C/C++ compilers, several additional system-dependent macros are also
defined.  These are described in this section.  See the WATCOM C Language
Reference manual for a description of the standard macros.

The Watcom C/C++ compilers run on various host operating systems including
DOS, OS/2, Windows NT, Windows 95 and QNX.  Any of the supported host
operating systems can be used to develop applications for a number of target
systems.  By default, the target operating system for the application is the
same as the host operating system unless some option or combination of
options is specified.  For example, DOS applications are built on DOS by
default, OS/2 applications are built on OS/2 by default, and so on.  But the
flexibility is there to build applications for other operating
systems/environments.

The macros described below may be used to identify the target system for
which the application is being compiled.  (Note:  In several places in the
following text, a pair of underscore characters appears as __ which
resembles a single, elongated underscore.)

The Watcom C/C++ compilers support both 16-bit and 32-bit application
development.  The following macros are defined for 16-bit and 32-bit target
systems.


      16-bit      32-bit
     ========    ========
     __X86__     __X86__
     __I86__     __386__
     M_I86       M_I386
     _M_I86      _M_I386
     _M_IX86     _M_IX86

Notes:

 1. The __X86__ identifies the target as an Intel environment.

 2. The __I86__,  M_I86 and _M_I86 macros identify the target as a 16-bit
    Intel environment.

 3. The __386__,  M_I386 and _M_I386 macros identify the target as a 32-bit
    Intel environment.

 4. The _M_IX86 macro is identically equal to 100 times the architecture
    compiler option value (/0, /1, /2, /3, /4, /5, etc.).  If "/5" (Pentium
    instruction timings) was specified as a compiler option, then the value
    of _M_IX86 would be 500.

The Watcom C/C++ compilers support application development for a variety of
operating systems.  The following macros are defined for particular target
operating systems.


     Target      Macros
     ======      ======================================
     DOS         __DOS__, _DOS, MSDOS
     OS/2        __OS2__
     QNX         __QNX__
     Netware     __NETWARE__, __NETWARE_386__
     NT          __NT__
     Windows     __WINDOWS__, _WINDOWS, __WINDOWS_386__

Notes:

 1. The __DOS__,  _DOS and MSDOS macros are defined when the build target is
    "DOS" (16-bit DOS or 32-bit extended DOS).

 2. The __OS2__ macro is defined when the build target is "OS2" (16-bit or
    32-bit OS/2).

 3. The __QNX__ macro is defined when the build target is "QNX" (16-bit or
    32-bit QNX).

 4. The __NETWARE__ and __NETWARE_386__ macros are defined when the build
    target is "NETWARE" (Novell NetWare).

 5. The __NT__ macro is defined when the build target is "NT" (Windows NT
    and Windows 95).

 6. The __WINDOWS__ macro is defined when the build target is "WINDOWS" or
    one of the "zw", "zW", "zWs" options is specified (identifies the target
    operating system as 16-bit Windows or 32-bit extended Windows but not
    Windows NT or Windows 95).

 7. The _WINDOWS macro is defined when the build target is "WINDOWS" or one
    of the "zw", "zW", "zWs" options is specified and you are using a 16-bit
    compiler (identifies the target operating system as 16-bit Windows).

 8. The __WINDOWS_386__ macro is defined when the build target is "WINDOWS"
    or the "zw" option is specified and you are using a 32-bit compiler
    (identifies the target operating system as 32-bit extended Windows).

The following macros are defined for the indicated options.


     Option    Macro
     ====== ==================
     bm     _MT
     br     _DLL
     fpi    __FPI__
     fpi87  __FPI__
     j      __CHAR_SIGNED__
     oi     __INLINE_FUNCTIONS
     za     NO_EXT_KEYS
     zw     __WINDOWS__
     zW     __WINDOWS__
     zWs    __WINDOWS__

The following memory model macros are defined for the indicated memory model
options.


     Option     All        16-bit only          32-bit only
     ====== =========== =================    =================
     mf     __FLAT__                         M_386FM  _M_386FM
     ms     __SMALL__   M_I86SM  _M_I86SM    M_386SM  _M_386SM
     mm     __MEDIUM__  M_I86MM  _M_I86MM    M_386MM  _M_386MM
     mc     __COMPACT__ M_I86CM  _M_I86CM    M_386CM  _M_386CM
     ml     __LARGE__   M_I86LM  _M_I86LM    M_386LM  _M_386LM
     mh     __HUGE__    M_I86HM  _M_I86HM

The following macros indicate which compiler is compiling the C/C++ source
code.

__cplusplus
    Watcom C++ predefines the macro __cplusplus to identify the compiler as
    a C++ compiler.

__WATCOMC__
    Watcom C/C++ predefines the macro __WATCOMC__ to identify the compiler
    as one of the Watcom C/C++ compilers.

    The value of the macro depends on the version number of the compiler.
     The value is 100 times the version number (version 8.5 yields 850,
    version 9.0 yields 900, etc.).

__WATCOM_CPLUSPLUS__
    Watcom C/C++ predefines the macro __WATCOM_CPLUSPLUS__ to identify the
    compiler as one of the Watcom C++ compilers.

    The value of the macro depends on the version number of the compiler.
     The value is 100 times the version number (version 10.0 yields 1000,
    version 10.5 yields 1050, etc.).

The following macros are defined for compatibility with Microsoft.

_fastcall, __fastcall
    Watcom C++ predefines the _fastcall and __fastcall macros to an empty
    string so that source code containing this Microsoft keyword can be
    compiled without syntax errors.  The _fastcall keyword refers to a
    Microsoft calling convention that is not supported by Watcom C/C++.
     Watcom's calling conventions are already "fast" to start with; hence,
    the keyword is not required.

_inline, __inline
    Watcom C++ predefines the _inline and __inline macros to be identical to
    the inline keyword.

_PUSHPOP_SUPPORTED
    Watcom C/C++ predefines the _PUSHPOP_SUPPORTED macro to indicate that
    #pragma pack(push) and #pragma pack(pop) are supported.

_STDCALL_SUPPORTED
    Watcom C/C++ predefines the _STDCALL_SUPPORTED macro to indicate that
    the standard 32-bit Win32 calling convention is supported.

The following table summarizes the predefined macros supported by the
compilers and the values that the respective compilers assign to them.  A
"yes" under the column means that the compiler supports the macro with the
indicated value.  Note that the C and C++ compilers sometime support the
same macro but with different values (including no value which means the
symbol is defined without a value).

     Predefined Macro                Supported by Compiler
      and Setting                wcc     wcc386  wpp     wpp386
     --------------------------- ------  ------  ------  ------
     __386__=                                              Yes
     __386__=1                             Yes
     __3R__=                                               Yes
     _based=__based                Yes     Yes     Yes     Yes
     _cdecl=__cdecl                Yes     Yes     Yes     Yes
     _Cdecl=__cdecl                Yes     Yes     Yes     Yes
     cdecl=__cdecl                 Yes     Yes     Yes     Yes
     __cplusplus=1                                 Yes     Yes
     _DLL=                         Yes     Yes     Yes     Yes
     _export=__export              Yes     Yes     Yes     Yes
     _far16=__far16                Yes     Yes     Yes     Yes
     _Far16=__far16                Yes     Yes     Yes     Yes
     _far=__far                    Yes     Yes     Yes     Yes
     far=__far                     Yes     Yes     Yes     Yes
     __fastcall=                                   Yes     Yes
     _fastcall=                                    Yes     Yes
     _fastcall=__fastcall          Yes     Yes
     __FLAT__=                                             Yes
     __FLAT__=1                            Yes
     _fortran=__fortran            Yes     Yes     Yes     Yes
     fortran=__fortran             Yes     Yes     Yes     Yes
     __FPI__=                                      Yes     Yes
     __FPI__=1                     Yes     Yes
     _huge=__huge                  Yes     Yes     Yes     Yes
     huge=__huge                   Yes     Yes     Yes     Yes
     __I86__=                                      Yes
     __I86__=1                     Yes
     _inline=__inline              Yes     Yes
     __inline=inline                               Yes     Yes
     _inline=inline                                Yes     Yes
     _interrupt=__interrupt        Yes     Yes     Yes     Yes
     interrupt=__interrupt         Yes     Yes     Yes     Yes
     _loadds=__loadds              Yes     Yes     Yes     Yes
     _M_386FM=                                             Yes
     M_386FM=                                              Yes
     _M_I386=                                              Yes
     M_I386=                                               Yes
     M_I386=1                              Yes
     _M_I86=                                       Yes
     M_I86=                                        Yes
     M_I86=1                       Yes
     _M_I86SM=                                     Yes
     M_I86SM=                                      Yes
     _M_I86SM=1                    Yes
     M_I86SM=1                     Yes
     _M_IX86=0                     Yes             Yes
     _M_IX86=500                           Yes             Yes
     _MT=                          Yes     Yes     Yes     Yes

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson