Consider the following test code:
#include <tgmath.h>
void test()
{
double x=cos(4.5);
}
Compiling it as with
arm-none-eabi-gcc test.c -c
on Ubuntu 18.04 (gcc 6.3.1, newlib 2.4.0) works fine, but on Ubuntu 20.04 (gcc 9.2.1, newlib 3.3.0) I get the following errors:
In file included from test.c:1:
test.c: In function 'test':
test.c:5:14: error: 'ccosl' undeclared (first use in this function); did you mean 'ccosh'?
5 | double x=cos(4.5);
| ^~~
test.c:5:14: note: each undeclared identifier is reported only once for each function it appears in
test.c:5:14: error: argument 6 of '__builtin_tgmath' is not a function pointer
Apparently, the definition of cos
has somehow changed, so that it now mentions ccosl
which is not declared anywhere.
If I change from tgmath.h
to math.h
, the error no longer appears. This is of course just a workaround, not a fix, since this way I lose the type genericity for float
vs double
.
My question is: how do I make it work properly? Do I have to add some compilation option, or is it just a bug in the toolchain?