sincos() is a GNU extension provided by glibc. With Xcode 15.1 on Apple Silicon, we get the following error:
gcc -Wall -Wextra -Werror -O3 -march=native -o bench_fftw main.c -lfftw3 -lm
main.c:49:9: error: call to undeclared function 'sincos'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
sincos(angles[i], &sin_a, &cos_a);
^
main.c:49:9: note: did you mean '__sincos'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:658:29: note: '__sincos' declared here
__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp) {
We can, technically, use preprocessor directives to get around this; for example:
However, I feel that's not really elegant. To improve portability across platforms, we should switch to invoking sin() and cos() separately. Yes, this will be theoretically slower -- BUT many good compilers can detect this situation and perform optimization as necessary:
sincos()
is a GNU extension provided by glibc. With Xcode 15.1 on Apple Silicon, we get the following error:We can, technically, use preprocessor directives to get around this; for example:
However, I feel that's not really elegant. To improve portability across platforms, we should switch to invoking
sin()
andcos()
separately. Yes, this will be theoretically slower -- BUT many good compilers can detect this situation and perform optimization as necessary: