The header tgmath.h includes
math(5)
and defines several type-generic macros.
Of the math.h functions without an f
(float) or l (long double) suffix, several
have one or more parameters whose corresponding real type
is double. For each such function, except modf,
there is a corresponding type-generic macro.
The parameters whose corresponding real type is double
in the function synopsis are generic parameters. Use of
the macro invokes a function whose corresponding real type
and type domain are determined by the arguments for the
generic parameters.
NOTE:
Like other function-like macros in Standard libraries,
each type-generic macro can be suppressed to
make available the corresponding ordinary function.
Use of the macro invokes a function whose generic parameters
have the corresponding real type, determined by the following rules:
if any argument for generic parameters has type long double,
the type determined is long double.
if any argument for generic parameters has type double or
is of integer type, the type determined is double.
if the argument is not long double or double, its type is
determined as float.
NOTE:
If the type of the argument is not compatible with the type
of the parameter for the selected function, the behavior is
undefined.
For each unsuffixed function in math.h
the corresponding type-generic macro has the same
name as the function. These type-generic macros are
shown below:
Type-generic macros in tgmath.h
acos
acosh
asin
asinh
atan
atanh
atan2
cbrt
ceil
copysign
cos
cosh
erf
erfc
exp
exp2
expm1
fabs
fdim
floor
fma
fmax
fmin
fmod
frexp
hypot
ilogb
ldexp
lgamma
llrint
llround
log
log10
log1p
log2
logb
lrint
lround
nearbyint
nextafter
nexttoward
pow
remainder
remquo
rint
round
scalbn
scalbln
sin
sinh
sqrt
tan
tanh
tgamma
trunc
For example, using the following declarations:
#include <tgmath.h>
int n;
float f;
double d;
long double ld;
the following functions are invoked by use of type-generic
macros: