On 10/11/2021 16:31, David Brown wrote:
> On 10/11/2021 14:02, Bart wrote:
>> I don't care. I just want to call abs(). What the hell do I need to know
>> about tgmath for anyway?
>
> I know you don't care - you are proud of your ignorance in how the C
> language and how C implementations work.
I want to write a program and use abs().
That is not a very difficult operator to provide. You can write your own
versions easily enough, even as macros.
Yet languages generally provide it: Pascal, Python and C among many.
C is the exception in originally providing it as a bundled user-code
function, with multiple versions for different types, using either
stdlib.h or math.h or tgmath.h.
They may be various reasons why it was done like that in the neolithic
period when C first came out, but those are still the requirements now.
I believe that using tgmath.h instead of math.h emulates overloading of
fabs() for various float types, but I showed 3 compiler implementations
that had problems with it in 2021.
It IS a consequence of how C decided to do this stuff in the distant
past, and still does.
As it happens, I know how C deals with abs(), since I've implemented C.
> It means it works for people other than you.
> No, it might not work on /your/ installation. Other people manage fine.
> You seem to forget that - getting working C implementations is not
> rocket science. Breaking them as successfully and repeatedly as you do,
> /that/ takes some skill.
OK, YOU tell ME exactly how I managed to get the list of errors below,
since you're so much more skilled than I am:
The input is a file C:\c\c.c that contains:
#include <tgmath.h>
Installed is a 1.7GB installation of LLVM that includes clang.exe. And
a 2.8GB, 14,000-file installion of MSBuild tools or what is necessary to
run MSVC.
My contention is that it is how this language implements fundemental
features that makes it particularly prone to things going wrong like this.
Yours I already know:
* Bart doesn't know what the hello he's doing
* Microsoft don't know what the hell they're doing
* Windows is rubbish anyway
-------------------------------------------
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:72:50: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_acos(float _Complex __x) {return cacosf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:94:50: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl cacosf(_In_ _Fcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:76:50: error: passing
'_Complex double' to parameter of incompatible type '_Dcomplex' (aka
'struct _C_double_complex')
__tg_acos(double _Complex __x) {return cacos(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:69:49: note: passing
argument to parameter '_Z' here
_ACRTIMP _Dcomplex __cdecl cacos(_In_ _Dcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:80:56: error: passing
'_Complex long double' to parameter of incompatible type '_Lcomplex'
(aka 'struct _C_ldouble_complex')
__tg_acos(long double _Complex __x) {return cacosl(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:119:52: note: passing
argument to parameter '_Z' here
_ACRTIMP _Lcomplex __cdecl cacosl(_In_ _Lcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:101:50: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_asin(float _Complex __x) {return casinf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:97:50: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl casinf(_In_ _Fcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:105:50: error: passing
'_Complex double' to parameter of incompatible type '_Dcomplex' (aka
'struct _C_double_complex')
__tg_asin(double _Complex __x) {return casin(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:72:49: note: passing
argument to parameter '_Z' here
_ACRTIMP _Dcomplex __cdecl casin(_In_ _Dcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:109:56: error: passing
'_Complex long double' to parameter of incompatible type '_Lcomplex'
(aka 'struct _C_ldouble_complex')
__tg_asin(long double _Complex __x) {return casinl(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:122:52: note: passing
argument to parameter '_Z' here
_ACRTIMP _Lcomplex __cdecl casinl(_In_ _Lcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:130:50: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_atan(float _Complex __x) {return catanf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:99:50: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl catanf(_In_ _Fcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:134:50: error: passing
'_Complex double' to parameter of incompatible type '_Dcomplex' (aka
'struct _C_double_complex')
__tg_atan(double _Complex __x) {return catan(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:74:49: note: passing
argument to parameter '_Z' here
_ACRTIMP _Dcomplex __cdecl catan(_In_ _Dcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:138:56: error: passing
'_Complex long double' to parameter of incompatible type '_Lcomplex'
(aka 'struct _C_ldouble_complex')
__tg_atan(long double _Complex __x) {return catanl(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:124:52: note: passing
argument to parameter '_Z' here
_ACRTIMP _Lcomplex __cdecl catanl(_In_ _Lcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:159:52: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_acosh(float _Complex __x) {return cacoshf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:95:51: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl cacoshf(_In_ _Fcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:163:52: error: passing
'_Complex double' to parameter of incompatible type '_Dcomplex' (aka
'struct _C_double_complex')
__tg_acosh(double _Complex __x) {return cacosh(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:70:50: note: passing
argument to parameter '_Z' here
_ACRTIMP _Dcomplex __cdecl cacosh(_In_ _Dcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:167:58: error: passing
'_Complex long double' to parameter of incompatible type '_Lcomplex'
(aka 'struct _C_ldouble_complex')
__tg_acosh(long double _Complex __x) {return cacoshl(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:120:53: note: passing
argument to parameter '_Z' here
_ACRTIMP _Lcomplex __cdecl cacoshl(_In_ _Lcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:188:52: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_asinh(float _Complex __x) {return casinhf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:98:51: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl casinhf(_In_ _Fcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:192:52: error: passing
'_Complex double' to parameter of incompatible type '_Dcomplex' (aka
'struct _C_double_complex')
__tg_asinh(double _Complex __x) {return casinh(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:73:50: note: passing
argument to parameter '_Z' here
_ACRTIMP _Dcomplex __cdecl casinh(_In_ _Dcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:196:58: error: passing
'_Complex long double' to parameter of incompatible type '_Lcomplex'
(aka 'struct _C_ldouble_complex')
__tg_asinh(long double _Complex __x) {return casinhl(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:123:53: note: passing
argument to parameter '_Z' here
_ACRTIMP _Lcomplex __cdecl casinhl(_In_ _Lcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:217:52: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_atanh(float _Complex __x) {return catanhf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:100:51: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl catanhf(_In_ _Fcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:221:52: error: passing
'_Complex double' to parameter of incompatible type '_Dcomplex' (aka
'struct _C_double_complex')
__tg_atanh(double _Complex __x) {return catanh(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:75:50: note: passing
argument to parameter '_Z' here
_ACRTIMP _Dcomplex __cdecl catanh(_In_ _Dcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:225:58: error: passing
'_Complex long double' to parameter of incompatible type '_Lcomplex'
(aka 'struct _C_ldouble_complex')
__tg_atanh(long double _Complex __x) {return catanhl(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:125:53: note: passing
argument to parameter '_Z' here
_ACRTIMP _Lcomplex __cdecl catanhl(_In_ _Lcomplex _Z);
^
In file included from c.c:1:
C:\LLVM\lib\clang\11.0.0\include\tgmath.h:246:48: error: passing
'_Complex float' to parameter of incompatible type '_Fcomplex' (aka
'struct _C_float_complex')
__tg_cos(float _Complex __x) {return ccosf(__x);}
^~~
C:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\ucrt\complex.h:101:49: note: passing
argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl ccosf(_In_ _Fcomplex _Z);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.