TGMATH(3)
okay bestie, welcome to tgmath(3) β Library Functions Manual β and it's giving type-generic macros π
no cap, this header is lowkey iconic.
π NAME π
tgmath β type-generic macros β¨
π SYNOPSIS π
#include <tgmath.h>
π¦ DESCRIPTION π¦
okay so <tgmath.h> hands you type-generic macros for <math.h> and <complex.h> functions that have float (suffixed with f), double, and long double (suffixed with l) versions. The arguments that vary across the three functions and have type float, double, and long double, respectively, are called generic arguments. periodt.
Here are the actual rules for which function gets called when a type-generic macro is invoked, fr fr:
- If any generic argument has type
long doubleorlong double complex, thelong doublefunction is called. - Else, if any generic argument has type
double,double complex, or an integer type, thedoubleversion is invoked. - Otherwise, the macro expands to the
floatimplementation.
For these macros below, 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. iykyk πΈ
acos()β real function:acos(); complex function:cacos()asin()β real function:asin(); complex function:casin()atan()β real function:atan(); complex function:catan()acosh()β real function:acosh(); complex function:cacosh()asinh()β real function:asinh(); complex function:casinh()atanh()β real function:atanh(); complex function:catanh()cos()β real function:cos(); complex function:ccos()sin()β real function:sin(); complex function:csin()tan()β real function:tan(); complex function:ctan()cosh()β real function:cosh(); complex function:ccosh()sinh()β real function:sinh(); complex function:csinh()tanh()β real function:tanh(); complex function:ctanh()exp()β real function:exp(); complex function:cexp()log()β real function:log(); complex function:clog()pow()β real function:pow(); complex function:cpow()sqrt()β real function:sqrt(); complex function:csqrt()fabs()β real function:fabs(); complex function:cabs()
No complex functions exist for the following macros, so passing a complex value to a generic argument invokes undefined behaviour. not me making it dramatic, it's literally in the spec π
atan2()cbrt()ceil()copysign()erf()erfc()exp2()expm1()fdim()floor()fma()fmax()fmin()fmod()frexp()hypot()ilogb()ldexp()lgamma()llrint()llround()log10()log1p()log2()logb()lrint()lround()nearbyint()nextafter()nexttoward()remainder()remquo()rint()round()scalbn()scalbln()tgamma()trunc()
The following macros always expand to a complex function, no real option, periodt:
carg()cimag()conj()cproj()creal()
This header includes <complex.h> and <math.h>. π«Ά
π STANDARDS π
The header <tgmath.h> conforms to ISO/IEC 9899:1999 (βISO C99β). slay β¨
π HISTORY π
The header <tgmath.h> first appeared in FreeBSD 5.3. iconic behavior π
π§ COMPILER SUPPORT π§
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 _Generic() language keyword. In addition to compilers that support this keyword, this header file works with GCC. π
π BUGS π
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. yeah bestie, that's a real one ππ
xoxo, from Debian π dated January 4, 2012 π TGMATH(3) π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2004 Stefan Farfeleder
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms