Using and Porting GNU CC
GNU C supports complex data types. You can declare both complex integer
types and complex floating types, using the keyword
For example, `
__complex__ double x;' declares
x as a
variable whose real part and imaginary part are both of type
__complex__ short int y;' declares
have real and imaginary parts of type
short int; this is not
likely to be useful, but it shows that the set of complex types is
To write a constant with a complex data type, use the suffix `
j' (either one; they are equivalent). For example,
__complex__ float and
3i has type
__complex__ int. Such a constant always has a pure imaginary
value, but you can form any complex value you like by adding one to a
To extract the real part of a complex-valued expression exp, write
__real__ exp. Likewise, use
extract the imaginary part.
The operator `
~' performs complex conjugation when used on a value
with a complex type.
GNU CC can allocate complex automatic variables in a noncontiguous
fashion; it's even possible for the real part to be in a register while
the imaginary part is on the stack (or vice-versa). None of the
supported debugging info formats has a way to represent noncontiguous
allocation like this, so GNU CC describes a noncontiguous complex
variable as if it were two separate variables of noncomplex type.
If the variable's actual name is
foo, the two fictitious
variables are named
foo$imag. You can
examine and set these two fictitious variables with your debugger.
A future version of GDB will know how to recognize such pairs and treat them as a single variable with a complex type.