keil 局部变量不能查看值,显示为not in scope

用MDK调试一块STM32F207的程序,想查看一下变量却发现watch窗口总是

<not in scope>和<cannot evaluate>,无奈凑合着通过printf函数进行串口打印查看。

后来实在受不了,想了一下,觉得应该是编译器把这个局部变量给优化掉了,并没有在内存中生成,果断把优化级别改为Level 0,重新编译,解决。

Getting the Best Optimized Code for your Embedded Application 

ARM Compilation Tools 
The ARM Compilation Tools are the only compilation tool s co -developed with the ARM processors, and specifically 
designed to optimally support the ARM architecture. They are a result of 20 years of development, and are recognized as the 
industry -leading C and C++ compilation tools for the ARM, Thumb, and Thumb -2 instructions sets. 
The ARM Compilation tools consist of:  
•  The ARM Compiler, which enables you to compile C and C++ code. It is an optimizing compiler, and features 
command - line options to enable you to control the level of optimization  
•  Linker and Utilities, which assign addresses and lay out sections of code to form a final image  
•  A selection of libraries, including the ISO standard C libraries, and the MicroLIB C library which is optimized for 
embedded applications 
•  Assembler, which generates machine code instructions from  ARM, Thumb or Thumb-2 assembly- level   source code  
 
Compiler Options for Embedded Applications   
The ARM Compilation Tools include a number of compiler optimizations to help you best target your code for your chosen 
microcontroller device and   application area.   
They can be accessed from within µVision by clicking on Project –   Options for Target. 
T he options described this document  can be found on the Target   an d  C/C++   tabs  of   the  Options for Targets  dialog.  
 

MDK Compiler Optimizations   

•  Cross- Module  
Optimization  takes information from a prior build and uses it to place UNUSED functions into their 

own ELF section in the corresponding object file. This option is also known as Linker Feedback, and requires you to 
build your application twice to take adv antage of it for reduced code size.   
Cross-Module Optimization has been shown to reduce code size, by removing unused functions from your application. It 
can also improve the performance   of your application, by allowing modules to share inline code.  
 

•  The  M icroLIB   C library 
has been optimized to reduce the size of embedded applications. It is a subset of the ISO 

standard C runtime library, and offers a tradeoff between functionality and code size. Some of the st

  • 7
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值