Standard C++ Library Reference ISO/IEC (VERSION3)

declaration and achieves the same effect. The macro typically expands to an expression that
executes faster than a call to the function of the same name. The macro can, however, cause
confusion when you are tracing or debugging the program. So you can use a standard header in
two ways to declare or define a library function. To take advantage of any macro version,
include the standard header so that each apparent call to the function can be replaced by a
macro expansion.
For example:
#include <ctype.h>
char *skip_space(char *p)
{
while (isspace(*p)) can be a macro
++p;
return (p);
}
To ensure that the program calls the actual library function, include the standard header and
remove any macro definition with an undef directive.
For example:
#include <ctype.h>
#undef isspace remove any macro definition
int f(char *p) {
while (isspace(*p)) must be a function
++p;
You can use many functions in the library without including a standard header (although this
practice is no longer permitted in C99 and is generally not recommended). If you do not need
defined macros or types to declare and call the function, you can simply declare the function as
it appears in this chapter. Again, you have two choices. You can declare the function explicitly.
For example:
double sin(double x); declared in <math.h>
y = rho * sin(theta);
Or you can declare the function implicitly if it is a function returning int with a fixed number of
arguments, as in:
n = atoi(str); declared in <stdlib.h>
If the function has a varying number of arguments, such as printf, you must declare it
explicitly: Either include the standard header that declares it or write an explicit declaration.
Note also that you cannot define a macro or type definition without including its standard
header because each of these typically varies among implementations.