1tgmath.h(3HEAD) Headers tgmath.h(3HEAD)
2
3
4
6 tgmath.h, tgmath - type-generic macros
7
9 #include <tgmath.h>
10
11
13 The <tgmath.h> header includes the headers <math.h> and <complex.h> and
14 defines several type-generic macros.
15
16
17 Of the functions contained within the <math.h> and <complex.h> headers
18 without an f (float) or l (long double) suffix, several have one or
19 more parameters whose corresponding real type is double. For each such
20 function except modf(3M), there is a corresponding type-generic macro.
21 The parameters whose corresponding real type is double in the function
22 synopsis are generic parameters. Use of the macro invokes a function
23 whose corresponding real type and type domain are determined by the
24 arguments for the generic parameters.
25
26
27 Use of the macro invokes a function whose generic parameters have the
28 corresponding real type determined as follows:
29
30 o First, if any argument for generic parameters has type long
31 double, the type determined is long double.
32
33 o Otherwise, if any argument for generic parameters has type
34 double or is of integer type, the type determined is double.
35
36 o Otherwise, the type determined is float.
37
38
39 For each unsuffixed function in the <math.h> header for which there is
40 a function in the <complex.h> header with the same name except for a c
41 prefix, the corresponding type-generic macro (for both functions) has
42 the same name as the function in the <math.h> header. The corresponding
43 type-generic macro for fabs() and cabs() is fabs().
44
45
46
47
48 <math.h> Function <complex.h> Function Type-Generic Macro
49 ────────────────────────────────────────────────────────────────
50 acos() cacos() acos()
51 asin() casin() asin()
52 atan() catan() atan()
53 acosh() cacosh() acosh()
54 asinh() casinh() asinh()
55 atanh() catanh() atanh()
56 cos() ccos() cos()
57 sin() csin() sin()
58 tan() ctan() tan()
59 cosh() ccosh() cosh()
60 sinh() csinh() sinh()
61 tanh() ctanh() tanh()
62 exp() cexp() exp()
63 log() clog() log()
64 pow() cpow() pow()
65 sqrt() csqrt() sqrt()
66
67 fabs() cfabs() fabs()
68
69
70
71 If at least one argument for a generic parameter is complex, then use
72 of the macro invokes a complex function; otherwise, use of the macro
73 invokes a real function.
74
75
76 For each unsuffixed function in the <math.h> header without a c-pre‐
77 fixed counterpart in the <complex.h> header, the corresponding type-
78 generic macro has the same name as the function. These type-generic
79 macros are:
80
81 atan2() fma() llround() remainder()
82 cbrt() fmax() log10() remquo()
83 ceil() fmin() log1p() rint()
84 copysign() fmod() log2() round()
85 erf() frexp() logb() scalbn()
86 erfc() hypot() lrint() scalbln()
87 exp2() ilogb() lround() tgamma()
88 expm1() ldexp() nearbyint() trunc()
89 fdim() lgamma() nextafter()
90 floor() llrint() nexttoward()
91
92
93
94 If all arguments for generic parameters are real, then use of the macro
95 invokes a real function; otherwise, use of the macro results in unde‐
96 fined behavior.
97
98
99 For each unsuffixed function in the <complex.h> header that is not a c-
100 prefixed counterpart to a function in the <math.h> header, the corre‐
101 sponding type-generic macro has the same name as the function. These
102 type-generic macros are:
103
104 carg()
105 cimag()
106 conj()
107 cproj()
108 creal()
109
110
111
112 Use of the macro with any real or complex argument invokes a complex
113 function.
114
116 Functions invoked by use of type-generic macros are invoked with the
117 declarations listed below.
118
119 #include <tgmath.h>
120 int n;
121 float f;
122 double d;
123 long double ld;
124 float complex fc;
125 double complex dc;
126 long double complex ldc;
127
128
129
130 The following are the type-generic macros that invoke the functions
131 that are invoked with the preceding declarations.
132
133
134
135
136 Macro Use Invokes
137 ────────────────────────────────────────────────────────────
138 exp(n) exp(n), the function
139 acosh(f) acoshf(f)
140 sin(d) sin(d), the function
141 atan(ld) atanl(ld)
142 log(fc) clogf(fc)
143 sqrt(dc) csqrt(dc)
144 pow(ldc,f) cpowl(ldc, f)
145 remainder(n,n) remainder(n, n), the function
146 nextafter(d,f) nextafter(d, f), the function
147 nexttoward(f,ld) nexttowardf(f, ld)
148 copysign(n,ld) copysignl(n, ld)
149 ceil(fc) undefined behavior
150 rint(dc) undefined behavior
151 fmax(ldc,ld) undefined behavior
152 carg(n) carg(n), the function
153 cproj(f) cprojf(f)
154 creal(d) creal(d), the function
155 cimag(ld) cimagl(ld)
156 cabs(fc) cabsf(fc)
157 carg(dc) carg(dc), the function
158 cproj(ldc) cprojl(ldc)
159
160
162 See attributes(5) for descriptions of the following attributes:
163
164
165
166
167 ┌─────────────────────────────┬─────────────────────────────┐
168 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
169 ├─────────────────────────────┼─────────────────────────────┤
170 │Interface Stability │Standard │
171 └─────────────────────────────┴─────────────────────────────┘
172
174 modf(3M), complex.h(3HEAD), math.h(3HEAD), cabs(3M), fabs(3M),
175 attributes(5), standards(5)
176
177
178
179SunOS 5.11 17 Dec 2003 tgmath.h(3HEAD)