Mail Archives: djgpp/1999/10/06/16:06:21
On Wed, 6 Oct 1999, Andrew Hurrell wrote:
> However if is simply examine foo then I obtain the real part of the
> complex number. The only way I've found of obtaining the imaginary
> part of the number is to use *(&(foo)+1). However, I note from the
> gcc info page that gcc may store the real and imaginary parts of
> complex numbers in entirely separate locations, and thus I would
> guess that the above method is likely to be far from "safe".
I have no personal experience debugging C programs that use complex
variables. Anybody?
However, you could examine the code produced by the version of GCC you
are using now and establish whether it always stores the real and
imaginary part consecutively (it makes sense to me that it would). If
so, you could define a GDB function that prints foo and *(&foo+1)
automatically, and put the definition of this function into your gdb.ini
file. Then it would be more convenient for you to examine the values of
complex variables, and if GCC ever changes in this respect, you will need
to update your function. See the section about user-defined functions in
the GDB manual, for more details.
- Raw text -