C++ math functions not available in namespace std
Joel Sherrill
joel at rtems.org
Wed Jan 11 13:08:01 UTC 2023
This happens on the architectures where size of long double is not the same
as double. The header file disables everything if any math method is
missing.
I have it on my list to address. I was porting the long double methods from
FreeBSD before anyone ran into this but haven't finished
On Wed, Jan 11, 2023, 3:43 AM <Jan.Sommer at dlr.de> wrote:
> Hello and happy New Year,
>
> I stumbled upon a slightly weird problem with the current cross-compilers.
> According to https://en.cppreference.com/w/cpp/numeric/math/fmax
> std::fmax should be part of <cmath> for >= C++11.
> However, if I try to use it, I sometimes get "error: 'fmax' is not a
> member of 'std'; did you mean 'max'?"
>
> I do get the error when compiling the test file (see below) with
> i386-rtems6-g++ and riscv-rtems6-g++, but for example not for
> arm-rtems6-g++.
> If I use "fmax" instead of "std::fmax" the file compiles for all 3
> architectures.
> However, I have a library which uses the math functions with the namespace
> qualifier, which I cannot change that easily.
>
> Does someone know, what is the reason for that behavior (I guess it's
> related to newlib?) and what a solution could look like?
>
> Best regards,
>
> Jan
>
>
> PS: My test file looks like this:
>
> #include <cmath>
>
> double test(double a, double b)
> {
> return std::fmax(a, b);
> }
>
>
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20230111/f2b7885b/attachment.htm>
More information about the users
mailing list