Thursday, April 7, 2022

[SOLVED] GCC: which targets support fixed-point types?

Issue

$ echo "_Fract x;" | gcc -xc -
<stdin>:1:1: error: fixed-point types not supported for this target

href="https://gcc.gnu.org/onlinedocs/gcc/Fixed-Point.html" rel="nofollow noreferrer">6.16 Fixed-Point Types (emphasis added):

As an extension, GNU C supports fixed-point types as defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point types in GCC will evolve as the draft technical report changes. Calling conventions for any target might also change. Not all targets support fixed-point types.

Question: which targets support fixed-point types?

Extra: Is it documented? How to derive it from GCC's source code?


UPD. May be useful: Clang does support fixed-point types via option -ffixed-point:

$ echo "_Fract x;" | clang -xc - -c -ffixed-point
# OK

Solution

I can confirm that GCC 11.2.0 on AVR does support fixed-point types. Sizes are:

sizeof(signed   short _Fract) == 1
sizeof(unsigned short _Fract) == 1

sizeof(signed   _Fract) == 2
sizeof(unsigned _Fract) == 2

sizeof(signed   long _Fract) == 4
sizeof(unsigned long _Fract) == 4

sizeof(signed   long long _Fract) == 8
sizeof(unsigned long long _Fract) == 8

sizeof(signed   short _Accum) == 2
sizeof(unsigned short _Accum) == 2

sizeof(signed   _Accum) == 4
sizeof(unsigned _Accum) == 4

sizeof(signed   long _Accum) == 8
sizeof(unsigned long _Accum) == 8

sizeof(signed   long long _Accum) == 8
sizeof(unsigned long long _Accum) == 8


Answered By - AlexDarkVoid
Answer Checked By - Marilyn (WPSolving Volunteer)