Re: no quadmath.h on ppc64 ?
Hi, Dennis.
On Tue, 17 Apr 2018, Dennis Clarke wrote:
>nix$ cat pq.c
Where does this test case file come from?
>nix$ grep "FLT128_DIG"
>/usr/local/gcc7/lib/gcc/powerpc64-unknown-linux-gnu/7.3.0/include/float.h
>#undef FLT128_DIG
>#define FLT128_DIG __FLT128_DIG__
Notice that FLT128_DIG comes from ISO/IEC TS 18661-3, and that standard
states that FLT128_DIG is only defined if you define
__STDC_WANT_IEC_60559_TYPES_EXT__ before including float.h:
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>
However, also notice that the standard is about the _Float128 type, not
about __float128 (although these types are somewhat related to each other).
>nix$ /usr/local/gcc7/bin/gcc -v -m64 -g -S -o pq.s pq.c
To get compiler support for the __float128 type, you also need to pass
-mfloat128 to the compiler.
>pq.c: In function 'main':
>pq.c:13:24: error: 'FLT128_DIG' undeclared (first use in this function);
>did you mean 'FLT_DIG'?
> int n, precision = FLT128_DIG + 2;
> ^~~~~~~~~~
> FLT_DIG
You could use __FLT128_DIG__, instead of FLT128_DIG, which I think is the
right thing to do when using the __float128 type.
You could also define __STDC_WANT_IEC_60559_TYPES_EXT__ before including
float.h, to get the definition of FLT128_DIG. However, I think that this
is a little bit misleading, in the sense that FLT128_DIG is supposed to be
used with _Float128, not __float128 (compiler people could correct me if
I'm wrong or being too picky about the standard).
>pq.c:13:24: note: each undeclared identifier is reported only once for
>each function it appears in
>pq.c:17:5: error: unknown type name '__float128'; did you mean '_Float128'?
> __float128 pi_quad = M_PIq;
> ^~~~~~~~~~
> _Float128
This will be fixed by passing -mfloat128 to the compiler.
>pq.c:17:26: error: 'M_PIq' undeclared (first use in this function); did
>you mean 'M_PI'?
> __float128 pi_quad = M_PIq;
> ^~~~~
> M_PI
This should be defined in quadmath.h, but I noticed that you commented out
the inclusion of this header. Why?
>pq.c:25:9: warning: implicit declaration of function
>'quadmath_snprintf'; did you mean '__builtin_snprintf'?
>[-Wimplicit-function-declaration]
> n = quadmath_snprintf ( buf, buf_len, "%Qg", pi_quad );
> ^~~~~~~~~~~~~~~~~
> __builtin_snprintf
Likewise.
>pq.c:47:18: warning: implicit declaration of function 'strtoflt128'; did
>you mean 'strtoull'? [-Wimplicit-function-declaration]
> my_pi_quad = strtoflt128 (
>"3.1415926535897932384626433832795028841971", NULL );
> ^~~~~~~~~~~
> strtoull
Likewise.
Reply to: