variable optimized out

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

variable optimized out

Jump to solution
838 Views
AhmadTurkmani
Contributor II

hi,

im trying to read a led using the function Dio_ReadChannel. my code is written as shown below:

while (1)
{

Dio_WriteChannel(DioConf_DioChannel_myled, STD_HIGH);
TestDelay(5000000);
Dio_ReadChannel(DioConf_DioChannel_myled);
if ( Dio_ReadChannel(DioConf_DioChannel_myled) == true)
{
x = 1;

}
else
x=0;

im always getting x as an optimized out:

AhmadTurkmani_0-1692278093832.png

i want to see the value of my variable can anyone help me?

thank you.

0 Kudos
1 Solution
774 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AhmadTurkmani 

Go to the project properties -> C/C++ Build -> Settings -> Optimization. 

VaneB_0-1692633933320.png

 

View solution in original post

3 Replies
824 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AhmadTurkmani 

It means you compiled an optimization level different than the default, so the gcc optimizer found that some of your variables were redundant in some way that allowed them to be optimized away. Compile with optimization disabled if you want to see such variables (this is generally a good idea for debug builds in any case).

 

B.R.

VaneB

0 Kudos
803 Views
AhmadTurkmani
Contributor II
How can i disable optimization?
0 Kudos
775 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AhmadTurkmani 

Go to the project properties -> C/C++ Build -> Settings -> Optimization. 

VaneB_0-1692633933320.png