Re: how to find out the address of a variable after I compile the C file



"pete" <pfiland@xxxxxxxxxxxxxx> wrote in message news:446BC3FE.3BB4@xxxxxxxxxxxxxxxxx
bijayadipti@xxxxxxxxx wrote:
I have a C program. I have compiled it uisng gcc and also avr-gcc. Now
after compiling, I want to know the addresses of the two variables in
my program. Is there any options that I can use to find that out? Is
there any way at all to find that out? Someone told that it was
possible but I am not able to find out.

If a variable is local to a function other than main,
then it may or may not have the same address,
each time the function is called during the run of the program.

On some (many?) architectures, even globals, statics, and main()'s locals will vary across runs. In the case of recursive functions, different instances of the same locals may exist in several places.

The only decent answers are "find out with the & operator at runtime" or "use a debugger".

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin


*** Posted via a free Usenet account from http://www.teranews.com ***
.



Relevant Pages

  • Re: Best practice using large objects in foreach
    ... practice people feel is for using large objects in a foreach loop. ... example if you are reusing an Image object in a loop like this (letters ... The scope of locals ... If you try compiling ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Are locals evil?
    ... code as suggested for the recursive functions, ... words that shared the same locals in order not to clobber values. ... The problem, though, is that there's doesn't seem to be a standard way to reference words masked by redefinitions. ... If I want to debug word1, I cannot reference x without "forgetting" the re-definition of x. ...
    (comp.lang.forth)
  • Re: Long.valueOf(long) CodeAttribute max_locals wrong?
    ... final int offset = 128; ... view" of local variables, or with the JVM view of local variables? ... Compiling code with debug information should provide proper initialization code for the final int offset, because debuggers may access the names and/or values of the local variables. ... public class Locals { ...
    (comp.lang.java.machine)
  • Re: Anyone have some good visual references on the St Peter SS in the Midwest?
    ... What got me into this were some locals wanting more info on ... the local sand mines. ... Here is a short description of the St. Pete in Indiana. ... I'll try to drum up some more references. ...
    (sci.geo.geology)
  • Re: ANS Forth portability issue
    ... When locals are used in a colon definition some systems put ... one or more locals wordlists at the head of the search order, ... When compiling, the compiler looks ...
    (comp.lang.forth)