variable optimized out

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

variable optimized out

跳至解决方案
1,579 次查看
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 项奖励
回复
1 解答
1,515 次查看
VaneB
NXP TechSupport
NXP TechSupport

Hi @AhmadTurkmani 

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

VaneB_0-1692633933320.png

 

在原帖中查看解决方案

3 回复数
1,565 次查看
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 项奖励
回复
1,544 次查看
AhmadTurkmani
Contributor II
How can i disable optimization?
0 项奖励
回复
1,516 次查看
VaneB
NXP TechSupport
NXP TechSupport

Hi @AhmadTurkmani 

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

VaneB_0-1692633933320.png