Re: No symbol "xx" in current context.

Compass <luopan81@xxxxxxxxx> wrote:
I have a class in file1.cpp file1.h. The main in main.cpp.
Compiled with:
g++ -g -c file1.cpp -o file1.o
g++ -g -c main.cpp -o main.o
g++ file1.o main.o -o main
Then gdb main
I can't print local vars in file1.cpp.
Is there anything wrong?

You're really not giving too much details so all I can do
is guess. It could be that the compiler has "optimized out"
those local variables, just keeping them in CPU registers
instead of using memory on the stack, so for the debugger
they don't exist as variables. Try to compile again with
the additional '-O0' option (that's an uppercase 'o' letter,
followed by a zero) to keep the compiler from doing any
optimizations and see if it then works.

Regards, Jens
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx

Relevant Pages

  • Re: updating through a loop statement
    ... optimizations. ... about the local variables. ... What articles/research can you reference that leads you to that conclusion? ... T-SQL is still a one-pass compiler without any ...
  • Re: WaitForSingleObject() will not deadlock
    ... One is to hijack the semantics of volatile to disable compiler optimizations ... and otherwise let the compiler to agressive optimization. ... Agressive optimizations are the ones that work on the edge of the semantics of the ... Because the compiler can see into lock and unlock, it is able to reduce f ...
  • Re: WaitForSingleObject() will not deadlock
    ... represent an incorrect implementation of the language. ... the *compiler* does not guarantee this. ... but to state it in terms of the execution instead of the formal semantics of the language ... as long as the optimizations do not change the semantics of the language). ...
  • Re: optimized code
    ... > loop invariants are handled by the JIT not by the compiler fron-ends. ... generates the best optimized MSIL of any of the .NET languages. ... standard native code optimizations on MSIL code. ...
  • Re: c compilation - gcc vs visual c
    ... I recently compiled a numerically intensive c project under cygwin gcc ... MS focuses a lot more on specific optimizations, ... the simplest approach, however (and the one I currently use in my compiler), ... (silly code), are ones I focus on fixing. ...