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 - made. http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
        made.

__syscall
    (32-bit only) The __syscall keyword may be used with function
    definitions, and indicates that the calling convention used is
    compatible with functions provided by 32-bit OS/2.

    Notes:

     1. Symbols names are not modified, that is, they are not adorned with
        leading or trailing underscores.

     2. Arguments are pushed on the stack from right to left.  That is, the
        last argument is pushed first.  The calling routine will remove the
        arguments from the stack.

     3. When a structure is returned, the caller allocates space on the
        stack.  The address of the allocated space will be pushed on the
        stack immediately before the call instruction.  Upon returning from
        the call, register EAX will contain address of the space allocated
        for the return value.  Floating-point values are returned in 80x87
        register ST(0).

     4. Registers EAX, ECX and EDX are not saved and restored when a call is
        made.

    Watcom C/C++ predefines the macros _syscall,  _System,  SOMLINK (32-bit
    only) and SOMDLINK (32-bit only) to be equivalent to the __syscall
    keyword.

__far16
    (32-bit only) Watcom C/C++ recognizes the __far16 keyword which can be
    used to define far 16-bit (far16) pointers (16-bit selector with 16-bit
    offset) or far 16-bit function prototypes.  This keyword can be used
    under 32-bit OS/2 to call 16-bit functions from your 32-bit flat model
    program.  Integer arguments will automatically be converted to 16-bit
    integers, and 32-bit pointers will be converted to far16 pointers before
    calling a special thunking layer to transfer control to the 16-bit
    function.

    Watcom C/C++ predefines the macros _far16 and _Far16 to be equivalent to
    the __far16 keyword.  This keyword is compatible with Microsoft C.

    In the OS/2 operating system (version 2.0 or higher), the first 512
    megabytes of the 4 gigabyte segment referenced by the DS register is
    divided into 8192 areas of 64K bytes each.  A far16 pointer consists of
    a 16-bit selector referring to one of the 64K byte areas, and a 16-bit
    offset into that area.

    A pointer declared as,


     [type] __far16 *name;

    defines an object that is a far16 pointer.  If such a pointer is
    accessed in the 32-bit environment, the compiler will generate the
    necessary code to convert between the far16 pointer and a "flat" 32-bit
    pointer.

    For example, the declaration,


         char __far16 *bufptr;

    declares the object bufptr to be a far16 pointer to char.

    A function declared as,


     [type] __far16 func( [arg_list] );

    declares a 16-bit function.  Any calls to such a function from the
    32-bit environment will cause the compiler to convert any 32-bit pointer
    arguments to far16 pointers, and any int arguments from 32 bits to 16
    bits.  (In the 16-bit environment, an object of type int is only 16
    bits.) Any return value from the function will have its return value
    converted in an appropriate manner.

    For example, the declaration,


         char * __far16 Scan( char *buffer, int len, short err );

    declares the 16-bit function Scan.  When this function is called from
    the 32-bit environment, the buffer argument will be converted from a
    flat 32-bit pointer to a far16 pointer (which, in the 16-bit
    environment, would be declared as char __far *.  The len argument will
    be converted from a 32-bit integer to a 16-bit integer.  The err
    argument will be passed unchanged.  Upon returning, the far16 pointer
    (far pointer in the 16-bit environment) will be converted to a 32-bit
    pointer which describes the equivalent location in the 32-bit address
    space.
_Seg16
    (32-bit only) Watcom C/C++ recognizes the _Seg16 keyword which has a
    similar but not identical function as the __far16 keyword described
    above.  This keyword is compatible with IBM C Set/2.

    In the OS/2 operating system (version 2.0 or higher), the first 512
    megabytes of the 4 gigabyte segment referenced by the DS register is
    divided into 8192 areas of 64K bytes each.  A far16 pointer consists of
    a 16-bit selector referring to one of the 64K byte areas, and a 16-bit
    offset into that area.

    Note that _Seg16 is not interchangeable with __far16.

    A pointer declared as,


     [type] * _Seg16 name;

    defines an object that is a far16 pointer.  Note that the _Seg16 appears
    on the right side of the * which is opposite to the __far16 keyword
    described above.

    For example,


         char * _Seg16 bufptr;

    declares the object bufptr to be a far16 pointer to char (the same as
    above).

    The _Seg16 keyword may not be used to describe a 16-bit function.  A
    #pragma directive must be used instead.  A function declared as,


     [type] * _Seg16 func( [parm_list] );

    declares a 32-bit function that returns a far16 pointer.

    For example, the declaration,


         char * _Seg16 Scan( char * buffer, int len, short err );

    declares the 32-bit function Scan.  No conversion of the argument list
    will take place.  The return value is a far16 pointer.

__pragma
    Watcom C++ supports the __pragma keyword to support in-lining of member
    functions.  The __pragma keyword must be followed by parentheses
    containing a string that names an auxiliary pragma.  Here is a
    simplified example showing usage and syntax.

    Example:

         #pragma aux fast_mul = \
             "imul eax,edx" \
             parm caller [eax] [edx] \
             value struct;

         struct fixed {
             unsigned v;
         };

         fixed __pragma( "fast_mul") operator *( fixed, fixed );

         fixed two = { 2 };
         fixed three = { 3 };

         fixed foo()
         {
             return two * three;
         }

    See the chapters entitled 16-bit Pragmas and 32-bit Pragmas for more
    information on pragmas.

__int64
    Watcom C/C++ supports the __int64 keyword to define 64-bit integer data
    objects.

    Example:

         static __int64 bigInt;

    Also supported are signed and unsigned 64-bit integer constants.

    signed __int64
        Use the "i64" suffix for a signed 64-bit integer constant.

        Example:

             12345i64
             12345I64

    unsigned __int64
        Use the "ui64" suffix for a signed 64-bit integer constant.

        Example:

             12345Ui64
             12345uI64


    The run-time library supports formatting of __int64 items (see the
    description of the printf library function).

    Example:

         #include <stdio.h>
         #include <limits.h>

         void main()
         {
             __int64 bigint;
             __int64 bigint2;

             bigint2 = 8I64 * (LONG_MAX + 1I64);
             for( bigint = 0;
                  bigint <= bigint2;
                  bigint += bigint2 / 16 ) {
                 printf( "Hello world %Ld\n", bigint );
             }
         }

    Restrictions

    switch
        An __int64 expression cannot be used in a switch statement.

    bit fields
        More than 32 bits in a 64-bit bitfield is not supported.

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