delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/06/16:06:21

Date: Wed, 6 Oct 1999 17:16:02 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Andrew Hurrell <andrew AT amh-consulting DOT freeserve DOT co DOT uk>
cc: djgpp AT delorie DOT com
Subject: Re: complex numbers
In-Reply-To: <000601bf0fff$7b54dee0$6032893e@amh-home>
Message-ID: <Pine.SUN.3.91.991006171138.13916d-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019