用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