Re: undefined variable problem

Bart Vandewoestyne wrote:
On 2007-03-30, Bart Vandewoestyne <MyFirstName.MyLastName@xxxxxxxxxx> wrote:
I am a bit confused...


Reference to undefined variable A
Program terminated by fatal error

Hmmm... seems like I experienced the same problem a little while

So probably the problem will not be an undefined variable but
something else...

I'll check my code with different compilers to see if i can find
that nasty bug... and after fixing it i hope I also get rid of
the above error message...


Check out Catherine's reply again. I think you may have misunderstood what the compiler means by "undefined". It doesn't mean "not allocated" or "not declared" or "not associated". It means "used before set" - i.e. no value has been assigned to a since it was created (by allocation or whatever). It is an error to use the value of a variable if it has never been given a value, and that is what the compiler is complaining about.

In this instance, checking the code with different compilers will probably not help. Most compilers do not spot this type of error, but that doesn't mean there is no error - just that you are lucky to have one that does spot it.

John Appleyard - (send email to john!news@.. rather than spamtrap@..)
Polyhedron Software
Programs for Programmers - QA, Compilers, Graphics, Consultancy
********* Visit our Web site on *********

Relevant Pages

  • Re: breakpoints
    ... exit!= enter debugger ... spot with some of the compilers I use. ...
  • Re: Rtos Design
    ... Stacks for separate threads or processes can be allocated using the usual static ... it is usually advisable to use static allocation and to avoid run-time ... compilers But I believe I've read ... Now, in writing an operating system for micro/embedded use, I've never ...
  • Re: ALLOCATABLE arrays
    ... One reason for using the stack ... allocation tends to be very fast, ... Some compilers seem to be "smart" about working around the limits, ...
  • Varying allocation size for stack variables...
    ... YES THIS IS AN ASM QUESTION... ... I realize compilers might vary and also ... 'gcc memory allocation' and 'gcc local variable allocation' with no ...
  • Ragged Arrays
    ... new twist to the rugged array problem: ... Green Hills compilers also have it. ... This kind of thing is trivial to do in C, because C string ... >>allocation is not needed as well. ...