CKTIS / C
_Complex — complex number types
_Complex forms floating-point complex types that store real and imaginary components. Support is optional.
Version: C23; repository compiler flag, production runtime not attested
Syntax
float _Complex z;
double _Complex z;
long double _Complex z;_Complex is a type-specifier keyword. Combine it with float, double, or long double; _Complex alone is not a valid type declaration.
The <complex.h> header defines the complex macro expanding to _Complex. CMPLX(x, y) constructs a double _Complex value; creal and cimag extract its components. Do not pass a complex value directly to printf with %f.
Support is optional: __STDC_NO_COMPLEX__ with value 1 signals its absence. The example deliberately reports a compilation error in that case.
Examples
#include <stdio.h>
#ifdef __STDC_NO_COMPLEX__
#error Complex arithmetic is required
#else
#include <complex.h>
int main(void)
{
double _Complex z = CMPLX(3.0, 4.0);
printf("real=%.0f imag=%.0f\n", creal(z), cimag(z));
return 0;
}
#endif
Result
real=3 imag=4
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.