HP C/iX Reference Manual (31506-90011)
176 Chapter10
Using Intrinsics
Intrinsic Pragma
Intrinsic Pragma
You use the intrinsic pragma to declare an external function as an intrinsic. It has the
following format:
#pragma intrinsic
intrinsic-name
1[
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.