Value <unavailable> in IAR

2.6k Views Asked by At

I am using IAR (Version: 6.60.1.5104) to run my C project.

I am seeing a strange behavior.

While debugging I am getting the value of a variable defined locally as zero

eg.

int a = 0

But for a variable assigned a non-zero value is <available>.

I have mentioned a code snippet below:

int someFun():
{
    int32_t a = 0; //IAR says it <unavailable>
    int32_t b = 1;
    printf("%d%d", a,b);
}

This is consistently happening. Please help

1

There are 1 best solutions below

3
On

This probably just means that the variable has been optimized away, i.e. when the program runs there is no variable. Since the variable's value is never changed, an optimizing compiler is free to remove it and just make the printf() call use the values directly.

Disassemble the program to see how the call is generated.

Investigate how to disable compiler optimizations for your particular compiler (read the docs).