Library Functions and Header File Macros [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
Library Functions and Header File Macros
The HP C/iX library contains both functions and macros. Macros improve
the execution speed of certain frequently used operations. One drawback
to using macros is that they do not have an address. For example, if a
function expects the address of (a pointer to) another function as an
argument, you cannot use a macro name in that argument. The following
example illustrates the drawback:
#define add1(x) ((x)+=1)
extern f(void some_function( ));
main(void)
{
:
f(add1); /* This construct is illegal. */
:
}
Using add1 as an argument causes an error. To override a possible macro
and ensure that a library function is referenced as a true function, you
can do any of the following:
* Use the #undef directive, which causes the function name to no
longer be defined as a macro.
* Enclose the function name in parentheses to suppress macro
expansion.
* Take the address of the function using the & operator.
There are three ways in which a function can be declared:
* In a header file (which might generate a macro). This is the
safest method to declare a standard library function.
#include <stdlib.h>
m=abs(n);
* By explicit declaration. Make sure that your declaration matches
the one in this manual.
extern int abs(int j);
m=abs(n);
* By implicit declaration, if the function return type is int.
m=abs(n);
MPE/iX 5.0 Documentation