以下结论是实测得出的: 如果定义在函数内部,则占用RAM空间:0x200005f4 如果定义为全局变量则占rom空间。0x80064e4 帮助中“IAR C/C++ Development Guide” 描述如下: DECLARING OBJECTS CONST The const type qualifier is used for indicating that a data object, accessed directly or via a pointer, is non-writable. A pointer to const declared data can point to both constant and non-constant objects. It is good programming practice to use const declared pointers whenever possible because this improves the compiler’s possibilities to optimize the generated code and reduces the risk of application failure due to erroneously modified data. Static and global objects declared const are allocated in ROM. In C++, objects that require runtime initialization cannot be placed in ROM. 也就是说如果定义在函数内部的话,需要加上static
文章评论(0条评论)
登录后参与讨论