当前位置:网站首页>keil debug查看变量提示not in scope
keil debug查看变量提示not in scope
2022-06-25 06:33:00 【一只小阿大:)】
问题截图:
编译的时候还爆了个警告:…\src\user_main.c(155): warning: #550-D: variable “crc_buffer” was set but never used
我开始是在更改变量类型,从uint32_t改成了uint8_t,uint16_t,uint64_t发现都不行,我想是不是给优化掉了,然后更改了优化等级如下图,从Level 3更改成了Level 0发现还是不行。

但我依然想着是被优化掉了,但是没想到方法。
我就解决了这个警告,使用了这个变量,哪怕这个变量使用方式是错误的,但是我可以看到数值了,如下图。
我后面请教了现在公司带我的师傅(赵老师),然后他给我提示我使用volatile,然后我发现可以看见数值了,然后他又让我换成了static,我发现也可以,然后又给我提示了下让我想想之前我参数变量放在哪个区域(栈),让我自己想了。
我的想法(如果错误望指正):
编译器优化,指挥优化栈中的变量,如果不优化栈中的变量,那么就像我很多的变量声明了但未使用,很容易导致栈溢出问题。加volatile关键字就是不让编译器优化栈中的这个变量,使用static的时候这个变量不存放在栈中,而是存放在静态变量区(堆),那么也不会被优化。
经过上面的想法,我就想如果这样的话,我把变量变成全局变量是不是也没有问题,事实就是没有问题。
我又更改了优化等级,从Level 0 更改成了不使用(default),并且变量还是放在栈(局部变量)中,发现还是not in scope
我后续看很多文章解决这个问题的,都是写更改优化等级,但都没写在点上,为啥要更改优化等级?还有其他方式防止优化吗?
经过此事我也对编译器优化有了一点点了解。
边栏推荐
- @The difference between notempty, @notnull and @notblank
- ACWING2013. 三条线
- Wechat applet authorization login + mobile phone sending verification code +jwt verification interface (laravel8+php)
- JD 8 fleet stores search history, deletes history, clears history (not finished)
- Acwing / 2004. Mauvaise écriture
- Preliminary practice of niuke.com (summary)
- JS dynamic table creation
- What is the slice flag bit
- Analysis report on global and Chinese pharmaceutical excipients industry competition and marketing model 2022-2028
- System dilemma and software complexity: Why are our systems so complex?
猜你喜欢
![[speech discrimination] discrimination of speech signals based on MATLAB double threshold method [including Matlab source code 1720]](/img/36/ad86f403b47731670879f01299b416.jpg)
[speech discrimination] discrimination of speech signals based on MATLAB double threshold method [including Matlab source code 1720]

Monitoring access: how to grant minimum WMI access to the monitoring service account

Query process of MySQL secondary index

How two hosts in different network segments directly connected communicate

Cve-2022-23131 - bypass SAML SSO authentication

Understand what ICMP Protocol is

Wechat applet authorization login + mobile phone sending verification code +jwt verification interface (laravel8+php)

ctfshow-misc
![[Suanli network] technological innovation of Suanli Network -- Key Technologies of green and security](/img/52/7dedc5b6e213839fbf5cee3963ac99.jpg)
[Suanli network] technological innovation of Suanli Network -- Key Technologies of green and security

Zero foundation wants to learn web security, how to get started?
随机推荐
Rational investment and internationalism
百度地图——入门教程
Understand what MTU is
How to realize the stable output of 3.3v/3.6v (1.2-5v) voltage of lithium battery by using the voltage rise and fall chip cs5517
JD 8 fleet stores search history, deletes history, clears history (not finished)
ASP. Net core - Safety of asynclocal in asp NET Core
After unplugging the network cable, does the original TCP connection still exist?
Grouped uitableview has 20px of extra padding at the bottom
From file system to distributed file system
Monitoring access: how to grant minimum WMI access to the monitoring service account
Global and Chinese benzoic acid market competition strategy and demand scale forecast report 2022
How to configure log4j to only keep log files for the last seven days?
Sleep quality today 67 points
sin(a+b)=sina*cosb+sinb*cosa的推导过程
这些老系统代码,是猪写的么?
Research Report on brand strategic management and marketing trends in the global and Chinese preserved fruit market 2022
Research Report on investment share and application prospect of 1,3-propanediol (PDO) industry in the world and China 2022
Microsoft issued a document to celebrate Net 20th anniversary!
Are these old system codes written by pigs?
Aviator an expression evaluation engine