STM32F303: Where are __SOFT_FP, __ARM_FP, __GNUC__, __VFP_FP__, __SOFTFP__ defined?
Hi
Having generated a blank STM32F303 project in STM32CubeIDE, my main file has the following code
#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."
#endifMy compiler flags are among others -mfpu=fpv4-sp-d16 -mfloat-abi=hard
I get the following warning as a compilation output:
../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]
Full compiler invocation:
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."
| ^~~~~~~So I am wondering where these defines are hidden, but it seems very difficult to locate them. Digging deeper, I found the CMSIS specific "core_cm4.h" file, which has the following code:
#elif defined ( __GNUC__ )
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
#define __FPU_USED 1U__FPU_PRESENT is defined in a file called "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 */But it leaves me with the unknown __VFP_FP__ and __SOFTFP__ defines, which I cannot seem to find :\
I believe I went through all possible header and CMSIS files, but cannot seem to find the relevant defines. Is there anything magic happening behind the scenes that I am not aware of?
PS: I am using GNU GCC as a compiler/toolchain.
Thank you,
