C++ math functions not available in namespace std

Joel Sherrill joel at rtems.org
Wed Jan 11 16:03:30 UTC 2023


On Wed, Jan 11, 2023 at 8:46 AM <Jan.Sommer at dlr.de> wrote:

> Ah, thanks for the clarification.
>

FWIW in case someone looks at this, I think this impacts aarch64, x86,
powerpc, and maybe one other architecture. I just don't remember for sure.


> If I can be of any help with the porting, let me know.
>

Thanks. Maybe some testing.

--joel

>
>
>
>
> *From:* Joel Sherrill <joel at rtems.org>
> *Sent:* Mittwoch, 11. Januar 2023 14:08
> *To:* Sommer, Jan <Jan.Sommer at dlr.de>
> *Cc:* rtems-users at rtems.org <users at rtems.org>
> *Subject:* Re: C++ math functions not available in namespace std
>
>
>
> 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/dbfecf0d/attachment-0001.htm>


More information about the users mailing list