How do I know at preprocessing time which compiler option was chosen between FPv5-D16 and FPv5-SP-D16?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-23 5:48 AM
The __SIZEOF_FLOAT__ and __SIZEOF_DOUBLE__ macros give the same result in both cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-23 1:02 PM
Try to output all preprocessor symbols (macros), see e.g. https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines (which refers to gcc documentation).
Maybe there is some specific __TARGET_FPU_xx or alike.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-24 3:08 AM
Nice idea. Thank you.
I found a define quite useful:
__SOFTFP__ : is defined if soft FP is selected in configuration
__ARM_FP : is defined and set if hardware FP is selected in configuration
__ARM_FP Set if hardware floating-point is available.
Bits 1-3 indicate the supported floating-point precision levels. The other bits are reserved.
- Bit 1 - half precision (16-bit).
- Bit 2 - single precision (32-bit).
- Bit 3 - double precision (64-bit).
These bits can be bitwise or-ed together. Permitted values include:
- 0x04 for single-support.
- 0x0C for single- and double-support.
- 0x0E for half-, single-, and double-support.
On STM32H743:
with FPv5_SP_D16 I get 0x04
with FPv5_D16 I get 0x0E, but the same thing with none...
with softfp __ARM_FP is not defined
Same thing for __GCC_IEC_559 :
0 for FPv5_SP_D16 hard or soft, and soft+none
2 for FPv5_D16 or none hard or soft
But this only means that there is an implementation difference (with regard to the standard) between SP and DP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-24 5:51 AM
Well, then the answer to your original question is, "you don't". It *is* an unpleasant but valid answer.
Another, extreme maybe, answer is: gcc is open source, you can make whatever change you wish to it.
That much for academic and impractical answers. I'm sure you know the practical ones already.
JW
