So I am using Mac with the developer tools coming from XCode and according to other answers I should compile using something like:
g --std=c 17 test.cpp -o test
or using clang but I still I am having trouble making the script find the special functions. What else can I try?
Minimum example
#include <cmath>
#include <iostream>
int main(int argc, char *argv[]){
double x = 0.5;
double y = std::cyl_bessel_k(2,x);
std::cout << "x="<<x <<" -> y(x)="<<y <<std::endl;
return 0;
}
Error
main2.cpp:6:19: error: no member named 'cyl_bessel_k' in namespace 'std'
double y = std::cyl_bessel_k(2,x);
~~~~~^
1 error generated.
clang version 13.0.0
CodePudding user response:
https://en.cppreference.com/w/cpp/numeric/special_functions/cyl_bessel_j says:
Notes
Implementations that do not support C 17, but support ISO 29124:2010, provide this function if
__STDCPP_MATH_SPEC_FUNCS__is defined by the implementation to a value at least201003Land if the user defines__STDCPP_WANT_MATH_SPEC_FUNCS__before including any standard library headers.Implementations that do not support ISO 29124:2010 but support TR 19768:2007 (TR1), provide this function in the header
tr1/cmathand namespacestd::tr1.
Armed with your compiler version, I checked https://en.cppreference.com/w/cpp/compiler_support/17#C.2B.2B17_library_features and saw that neither Apple clang nor clang 's own stdlib have these functions. Bad news! You'll need to get them e.g. from boost, or by implementing them yourself. The example on https://en.cppreference.com/w/cpp/numeric/special_functions/cyl_bessel_j actually does have an implementation for you.
