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 - when a symbol referred to by an auxiliary pragma includes an alias name, the http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
When a symbol referred to by an auxiliary pragma includes an alias name, the
attributes of the alias name are also assumed by the specified symbol.

There are two methods of specifying alias information.  In the first method,
the symbol assumes only the attributes of the alias name; no additional
attributes can be specified.  The second method is more general since it is
possible to specify an alias name as well as additional auxiliary
information.  In this case, the symbol assumes the attributes of the alias
name as well as the attributes specified by the additional auxiliary
information.

The simple form of the auxiliary pragma used to specify an alias is as
follows.

+--------------------------------------------------------------------------+
|      #pragma aux ( sym, [far16] alias ) [;]                              |
|                                                                          |
+--------------------------------------------------------------------------+

where
    description

sym
    is any valid C/C++ identifier.

alias
    is the alias name and is any valid C/C++ identifier.

The far16 attribute should only be used on systems that permit the calling
of 16-bit code from 32-bit code.  Currently, the only supported operating
system that allows this is 32-bit OS/2.  If you have any libraries of
functions or APIs that are only available as 16-bit code and you wish to
access these functions and APIs from 32-bit code, you must specify the far16
attribute.  If the far16 attribute is specified, the compiler will generate
special code which allows the 16-bit code to be called from 32-bit code.
 Note that a far16 function must be a function whose attributes are those
specified by one of the alias names __cdecl or __pascal.  These alias names
will be described in a later section.

Consider the following example.


     #pragma aux push_args parm [] ;
     #pragma aux ( rtn, push_args ) ;

The routine rtn assumes the attributes of the alias name push_args which
specifies that the arguments to rtn are passed on the stack.

Let us look at an example in which the symbol is a type definition.


     typedef void (func_type)(int);

     #pragma aux push_args parm [];
     #pragma aux ( func_type, push_args );

     extern func_type rtn1;
     extern func_type rtn2;

The first auxiliary pragma defines an alias name called push_args that
specifies the mechanism to be used to pass arguments.  The mechanism is to
pass all arguments on the stack.  The second auxiliary pragma associates the
attributes specified in the first pragma with the type definition func_type.
 Since rtn1 and rtn2 are of type func_type, arguments to either of those
functions will be passed on the stack.

The general form of an auxiliary pragma that can be used to specify an alias
is as follows.

+--------------------------------------------------------------------------+
|      #pragma aux ( alias ) sym aux_attrs [;]                             |
|                                                                          |
+--------------------------------------------------------------------------+

where
    description

alias
    is the alias name and is any valid C/C++ identifier.

sym
    is any valid C/C++ identifier.

aux_attrs
    are attributes that can be specified with the auxiliary pragma.

Consider the following example.


     #pragma aux HIGH_C "*"                                 \
                        parm caller []                      \
                        value no8087                        \
                        modify [eax ecx edx fs gs];
     #pragma aux (HIGH_C) rtn1;
     #pragma aux (HIGH_C) rtn2;
     #pragma aux (HIGH_C) rtn3;

The routines rtn1, rtn2 and rtn3 assume the same attributes as the alias
name HIGH_C which defines the calling convention used by the MetaWare High C
compiler.  Note that register ES must also be specified in the "modify"
register set when using a memory model that is not a small data model.
 Whenever calls are made to rtn1, rtn2 and rtn3, the MetaWare High C calling
convention will be used.

Note that if the attributes of HIGH_C change, only one pragma needs to be
changed.  If we had not used an alias name and specified the attributes in
each of the three pragmas for rtn1, rtn2 and rtn3, we would have to change
all three pragmas.  This approach also reduces the amount of memory required
by the compiler to process the source file.

+--------------------------------------------------------------------------+
|   WARNING!  The alias name HIGH_C is just another symbol.  If HIGH_C     |
| appeared in your source code, it would assume the attributes specified   |
| in the pragma for HIGH_C.                                                |
+--------------------------------------------------------------------------+

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