有一段freerots里面的代码,第3,4,5,7行我没看明白,有朋友能帮忙一下吗?尤其是那个“@”。
/* Allocate the memory for the heap. */
#if configUSE_HEAP_SECTION_NAME && configCOMPILER==configCOMPILER_ARM_IAR /* << EST */
#pragma language=extended
#pragma location = configHEAP_SECTION_NAME_STRING
static uint8_t ucHeap[configTOTAL_HEAP_SIZE] @ configHEAP_SECTION_NAME_STRING;
#elif configUSE_HEAP_SECTION_NAME
static uint8_t __attribute__((section (configHEAP_SECTION_NAME_STRING))) ucHeap[configTOTAL_HEAP_SIZE];
#else
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#endif
伊谢尔伦2017-04-17 13:08:48
First of all, I won’t talk about the conditional compilation of #if. #pragma
and __atribute__
are both compiler preprocessing commands. #pragma location
and the following sentence are preprocessing commands related to the IAR
compiler. The purpose of these two sentences is to place the array ucHeap
at a specified address. The basic syntax is, #pragam location=地址
and 变量 @ 地址
. For specific syntax, see http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_DevelopmentGuide.ENU.pdf "Controlling data and function placement in memory" (page 218) That section __attribute__ section
means to put this array into the specified section. This is a compilation attribute of the GNU compiler.
So the meaning of this code is to define an array ucHeap and then determine whether to specify the address of this array according to the configuration
巴扎黑2017-04-17 13:08:48
These should be the extended functions and syntax of the compiler, especially the #pragma and __attribute__. Check what platform code this is, what compiler is used, and then check the compiler documentation
大家讲道理2017-04-17 13:08:48
You can put the variables together in a section. For example, if frequently accessed data is placed together, caching will be more effective.