STM32F303中 __SOFT_FP, __ARM_FP, __GNUC__, __VFP_FP__, __SOFTFP__ 再哪里定义的
STM32F303:SOFT_FP、ARM_FP、GNUC、VFP_FP、SOFTFP 是在哪里定义的?在 STM32CubeIDE 中生成一个空白的 STM32F303 项目后,我的主文件包含以下代码:
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
我的编译器标志包括 -mfpu=fpv4-sp-d16 -mfloat-abi=hard。
编译输出时出现以下警告:
../Src/main.c:10:4: warning: #warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use." [-Wcpp]
完整的编译器调用如下:
arm-none-eabi-gcc -mcpu=cortex-m4 -g3 -c -x assembler-with-cpp -MMD -MP -MF"Startup/startup_stm32f303cctx.d" -MT"Startup/startup_stm32f303cctx.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Startup/startup_stm32f303cctx.o" "../Startup/startup_stm32f303cctx.s"
arm-none-eabi-gcc "../Src/main.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DSTM32 -DSTM32F303xC -DSTM32F3 -DSTM32F303CCTx -DDEBUG -c -I../Inc -I../Drivers/CMSIS/Device/ST/STM32F3xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/main.d" -MT"Src/main.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Src/main.o"
arm-none-eabi-gcc "../Src/syscalls.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DSTM32 -DSTM32F303xC -DSTM32F3 -DSTM32F303CCTx -DDEBUG -c -I../Inc -I../Drivers/CMSIS/Device/ST/STM32F3xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/syscalls.d" -MT"Src/syscalls.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Src/syscalls.o"
arm-none-eabi-gcc "../Src/sysmem.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DSTM32 -DSTM32F303xC -DSTM32F3 -DSTM32F303CCTx -DDEBUG -c -I../Inc -I../Drivers/CMSIS/Device/ST/STM32F3xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/sysmem.d" -MT"Src/sysmem.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Src/sysmem.o"
arm-none-eabi-gcc "../Drivers/CMSIS/Device/ST/STM32F3xx/system_stm32f3xx.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DSTM32 -DSTM32F303xC -DSTM32F3 -DSTM32F303CCTx -DDEBUG -c -I../Inc -I../Drivers/CMSIS/Device/ST/STM32F3xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Drivers/CMSIS/Device/ST/STM32F3xx/system_stm32f3xx.d" -MT"Drivers/CMSIS/Device/ST/STM32F3xx/system_stm32f3xx.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Drivers/CMSIS/Device/ST/STM32F3xx/system_stm32f3xx.o"
../Src/main.c:10:4: warning: #warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use." [-Wcpp]
10 | #warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
| ^~~~~~~
因此,我想知道这些宏定义隐藏在哪里,但似乎很难找到它们。深入挖掘后,我发现了 CMSIS 特定的 core_cm4.h 文件,其中包含以下代码:
#elif defined ( __GNUC__ )
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
#define __FPU_USED 1U
__FPU_PRESENT 在 stm32f303xc.h 文件中定义:
#define __CM4_REV 0x0001U/*!< Core revision r0p1 */
#define __MPU_PRESENT 1U /*!< STM32F303xC devices provide an MPU */
#define __NVIC_PRIO_BITS 4U /*!< STM32F303xC devices use 4 Bits for the Priority Levels */
#define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 1U /*!< STM32F303xC devices provide an FPU */
但 __VFP_FP__ 和 __SOFTFP__ 的定义仍然未知,我似乎找不到它们。
我已经检查了所有可能的头文件和 CMSIS 文件,但仍然找不到相关的宏定义。
这好像 是跟平台有关的宏定义吧
页:
[1]