当前位置:网站首页>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
我后续看很多文章解决这个问题的,都是写更改优化等级,但都没写在点上,为啥要更改优化等级?还有其他方式防止优化吗?
经过此事我也对编译器优化有了一点点了解。
边栏推荐
- cos(a-b)=cosa*cosb+sina*sinb的推导过程
- From file system to distributed file system
- Rational investment and internationalism
- An interview question record about where in MySQL
- STL map的用法
- Pre knowledge of asynchronous operation
- Global and Chinese kaolin market operation scale and investment development proposal report 2022
- Ht513 I2S input 2.8W mono class D audio power amplifier IC
- 'how do I create an enumeration with constant values in rust?'- How can I create enums with constant values in Rust?
- Preliminary practice of niuke.com (summary)
猜你喜欢
![[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]](/img/4a/304f262c1c08800aa95f9e2d537e4d.jpg)
[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]

Ht513 I2S input 2.8W mono class D audio power amplifier IC

The five minute demonstration "teaches" actors to speak foreign languages and can seamlessly switch languages. This AI dubbing company has just received a round a financing of 20million US dollars
![[data visualization application] draw spatial map (with R language code)](/img/2d/04e5015573d10bdd6325ae497bfeb3.jpg)
[data visualization application] draw spatial map (with R language code)

How two hosts in different network segments directly connected communicate

The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse
![[short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]](/img/a1/0cb61368cb1d0817d74781084a4466.jpg)
[short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]

Meta universe is over, Web 3.0 will be fooled again?

How to deploy locally developed SAP ui5 applications to ABAP servers

Acwing / 2004. Mauvaise écriture
随机推荐
Is the number of indexes in a table the more the better?
JD 8 fleet stores search history, deletes history, clears history (not finished)
2022-02-19: fence installation. In a two-dimensional garden, there are some trees represented by (x, y) coordinates. As the installation cost is very expensive, your task is to enclose all the trees w
Handling skills of SQL optimization (2)
Understand what ICMP Protocol is
DataX tutorial (10) - hot plug principle of dataX plug-in
System dilemma and software complexity: Why are our systems so complex?
How to configure log4j to only keep log files for the last seven days?
Talk about TCP and UDP
[short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]
Why can't GC () free memory- Why does gc() not free memory?
What is the IP address
Go language library management restful API development practice
Exercise: completion
Analysis report on production and sales demand and sales prospect of global and Chinese phosphating solution Market 2022-2028
STL map的用法
Global and Chinese kaolin market operation scale and investment development proposal report 2022
Observation configuring wmic
After five years of software testing in ByteDance, I was dismissed in December to remind my brother of paddling
北京网上开股票账户安全吗?