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, alias ) [;]                                      |
|                                                                          |
+--------------------------------------------------------------------------+

where
    description

sym
    is any valid C/C++ identifier.

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

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 MS_C "_*"                                  \
                      parm caller []                        \
                      value struct float struct routine [ax]\
                      modify [ax bx cx dx es];
     #pragma aux (MS_C) rtn1;
     #pragma aux (MS_C) rtn2;
     #pragma aux (MS_C) rtn3;

The routines rtn1, rtn2 and rtn3 assume the same attributes as the alias
name MS_C which defines the calling convention used by the Microsoft C
compiler.  Whenever calls are made to rtn1, rtn2 and rtn3, the Microsoft C
calling convention will be used.

Note that if the attributes of MS_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 MS_C is just another symbol.  If MS_C         |
| appeared in your source code, it would assume the attributes specified   |
| in the pragma for MS_C.                                                  |
+--------------------------------------------------------------------------+

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