HP 3000 Manuals

Intrinsic Pragma [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

Intrinsic Pragma 

You use the intrinsic pragma to declare an external function as an
intrinsic.  It has the following format:

     #pragma intrinsic intrinsic-name1 [user-name] [,intrinsic-name2 [user-name] ]...

Where:

intrinsic-name        is the name of the intrinsic you want to call.

user-name             is any valid C identifier.  If specified, you must
                      use this name to invoke the intrinsic from the
                      source program.

Examples 

     #pragma intrinsic FOPEN
     #pragma intrinsic FCLOSE myfclose
     #pragma intrinsic FCHECK, FGETINFO
     #pragma intrinsic FWRITE mpe_fwrite, FREAD mpe_fread

The first example shows how to declare the FOPEN intrinsic as an external
function.  The second example shows how to declare FCLOSE; you must call
it by the name myfclose in your program.  The third and fourth examples
each declare two intrinsics.  The fourth provides alternative names for
the intrinsics.

When you designate an external function as an intrinsic, the compiler
refers to the intrinsic file to determine the function type, the number
of parameters, and the type of each parameter.  The compiler then uses
this information to perform the necessary conversions and insertions to
correctly invoke the routine, or to issue warnings and errors if proper
invocation is not possible.

Specifically, for intrinsic calls, the HP C/iX compiler does the
following:

   *   Converts all value parameters to the type expected by the
       intrinsic function.  Conversions are performed as if an assignment
       is done from the argument value to the formal parameter.  This is
       known as assignment conversion.  If a value cannot be converted,
       an error message is issued.

   *   Converts addresses passed as reference parameters to the proper
       address type.  This means that short addresses are coerced to long
       addresses as required by the intrinsic function.  An integer value
       of zero is considered a legal value (NULL) for any address
       parameter.

   *   Allows missing arguments in the call to the intrinsic if the
       intrinsic defines default values for those parameters.  The
       compiler supplies the default values for the missing arguments, or
       issues an error message if there is no defined default value.
       Missing arguments are allowed within an argument list or at the
       end of an argument list.

   *   Issues an error message if there are too many arguments.

   *   Inserts "hidden" arguments required to correctly call Pascal
       routines that have ANYVAR parameters (size is hidden) or that are
       EXTENSIBLE (parameter count is hidden).

If you declare a system intrinsic using an extern declaration rather than
an intrinsic program, and if you do not provide a function prototype,
none of the above checks, conversions, or insertions are done.  The
address of an intrinsic can be taken, but if a call is made using a
pointer to the intrinsic, the above checks are not performed.  The
intrinsic call then degenerates into a normal C function call.

To ensure that all calls are handled correctly by the compiler, the
intrinsic pragma should declare the name of the intrinsic using an
identifier with the identical case that is used by the function calls in
the program, especially if the optional user-name is not specified.  No
other functions in the program should have the same name as any intrinsic
that is declared, regardless of the case.  This is because the actual run
time symbol used to call an intrinsic is not necessarily the same case as
the identifier used to declare that intrinsic.

There are a few HP C library routines, such as fopen or fwrite, that have
the same names as intrinsic functions.  If you wish to call any of these
C library routines that always use lower case identifiers from a program
that also calls the intrinsics with the same name, the intrinsics must be
declared and called using mixed case or upper case identifiers, or by
using the optional user-name.



MPE/iX 5.0 Documentation