man.bsd.lv manual page server

Manual Page Search Parameters

TGMATH(3) Library Functions Manual TGMATH(3)

tgmathtype-generic macros

#include <tgmath.h>

The header <tgmath.h> provides type-generic macros for <math.h> and <complex.h> functions that have float (suffixed with ), double and long double (suffixed with ) versions. The arguments that vary across the three functions and have type float, double and long double, respectively, are called .

The following rules describe which function is actually called if a type-generic macro is invoked. If any generic argument has type long double or long double complex, the long double function is called. Else, if any generic argument has type double, double complex or an integer type, the double version is invoked. Otherwise, the macro expands to the float implementation.

For the macros in the following table, both real and complex functions exist. The real functions are prototyped in <math.h> and the complex equivalents in <complex.h>. The complex function is called if any of the generic arguments is a complex value. Otherwise, the real equivalent is called.

() acos() ()
() asin() ()
() atan() ()
() acosh() ()
() asinh() ()
() atanh() ()
() cos() ()
() sin() ()
() tan() ()
() cosh() ()
() sinh() ()
() tanh() ()
() exp() ()
() log() ()
() pow() ()
() sqrt() ()
() fabs() ()

No complex functions exist for the following macros, so passing a complex value to a generic argument invokes undefined behaviour:

() () () ()
() () () ()
() () () ()
() () () ()
() () () ()
() () () ()
() () () ()
() () () ()
() () ()
() () ()

The following macros always expand to a complex function:

() () () () ()

This header includes <complex.h> and <math.h>.

The header <tgmath.h> conforms to ISO/IEC 9899:1999 (“ISO C99”).

The header <tgmath.h> first appeared in FreeBSD 5.3.

Before ISO/IEC 9899:2011 (“ISO C11”), the header <tgmath.h> could not be implemented with strictly conforming C code and needed special compiler support. As of ISO/IEC 9899:2011 (“ISO C11”), this header file can be implemented using the () language keyword. In addition to compilers that support this keyword, this header file works with GCC.

Many of the functions mentioned here are not prototyped in <math.h> or <complex.h> as they are not yet implemented. This prevents the corresponding type-generic macro from working at all.

January 4, 2012 FreeBSD-12.0