We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
#define CAN_START_SEC_CONFIG_DATA_32 #include "Can_MemMap.h" uint32 Can_au32HwBufferAddr_Ctrl0[56U]={0}; uint32 Can_au32HwBufferAddr_Ctrl1[56U]={0}; #define CAN_STOP_SEC_CONFIG_DATA_32 #include "Can_MemMap.h" As shown above, I have defined the following variables in the C file. Then, as shown below, I use __attribute__ in CanMemMap.h to assign these two variables to a specific section. However, I found that only the first variable is assigned to this specific section, while the other variable is still in the default section. How can I ensure that both variables are assigned to this section? c 复制 #ifdef CAN_START_SEC_CONFIG_DATA_32 /** * @file Can_MemMap.h */ #undef CAN_START_SEC_CONFIG_DATA_32 #define ENTERED_CAN_START_SEC_CONFIG_DATA_32 #ifndef MEMMAP_MATCH_ERROR #define MEMMAP_MATCH_ERROR #else #ifndef CAN_STOP_SEC_CONFIG_DATA_32 #error "MemMap.h, no valid matching start-stop section defined." #endif #endif /** * @file Can_MemMap.h */ #undef MEMMAP_ERROR /* Save the current section settings */ #pragma GCC push_options /* Place all subsequent data definitions in the specified section */ __attribute__((section(".can_mcal_const_cfg_32"))) #endif #ifdef CAN_STOP_SEC_CONFIG_DATA_32 /** * @file Can_MemMap.h */ #ifdef ENTERED_CAN_START_SEC_CONFIG_DATA_32 #undef ENTERED_CAN_START_SEC_CONFIG_DATA_32 #else #error "MemMap.h, no valid matching start-stop section defined." #endif #ifdef MEMMAP_MATCH_ERROR #undef MEMMAP_MATCH_ERROR #endif #undef CAN_STOP_SEC_CONFIG_DATA_32 /** * @file Can_MemMap.h */ #undef MEMMAP_ERROR /* Restore the previous section settings */ #pragma GCC pop_options #endif Additionally, I need to clarify that I am using an ARM MCU with the gcc-arm-none-eabi-10-2020-q4-major compiler, and my variables are generated by a tool and cannot be changed.