CKTIS / C
_Imaginary — optional imaginary types
_Imaginary specifies a type holding a purely imaginary value. Support is optional: selecting C23 mode alone does not guarantee availability.
Version: C23; repository compiler flag, production runtime not attested
Syntax
float _Imaginary name;
double _Imaginary name;
long double _Imaginary name;Annex G.2 of draft N3096 describes float _Imaginary, double _Imaginary, and long double _Imaginary. Unlike _Complex, these represent only an imaginary component, not a pair of real and imaginary components.
Check implementation support before use. Do not infer it from a C23 flag; production-runtime behavior has not been attested.
The example includes <complex.h> unconditionally. C23 allows implementations without complex support to omit this header. If the #include directive does not identify a header the implementation can process, C23 requires a diagnostic but does not require translation to stop before the _Imaginary_I check. The example is not portable to implementations that omit the header. After the header is successfully included, if the _Imaginary_I macro is defined, the example constructs an imaginary value and converts it to _Complex to print both components. If the macro is not defined, the example prints imaginary types unavailable instead of using _Imaginary.
Examples
#include <complex.h>
#include <stdio.h>
int main(void)
{
#ifdef _Imaginary_I
double _Imaginary y = 3.0 * _Imaginary_I;
double _Complex z = y;
printf("%.0f %.0f\n", creal(z), cimag(z));
#else
puts("imaginary types unavailable");
#endif
return 0;
}
Result
imaginary types unavailable
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.