4.80 <tgmath.h> type-generic math macros in C99

The new standard header <tgmath.h> defines several families of mathematical functions that are type generic in the sense that they are overloaded on floating-point types.

For example, the trigonometric function cos works as if it has the overloaded declaration:
extern float cos(float x);
extern double cos(double x);
extern long double cos(long double x);
A statement such as:
p = cos(0.78539f); // p = cos(pi / 4)
calls the single-precision version of the cos function, as determined by the type of the literal 0.78539f.


Type-generic families of mathematical functions can be defined in C++ using the operator overloading mechanism. The semantics of type-generic families of functions defined using operator overloading in C++ are different from the semantics of the corresponding families of type-generic functions defined in <tgmath.h>.
Related concepts
4.60 New library features of C99
4.74 Additional <math.h> library functions in C99
4.75 Complex numbers in C99
4.76 Boolean type and <stdbool.h> in C99
4.77 Extended integer types and functions in <inttypes.h> and <stdint.h> in C99
4.78 <fenv.h> floating-point environment access in C99
4.79 <stdio.h> snprintf family of functions in C99
4.81 <wchar.h> wide character I/O functions in C99
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.