C++ math functions not available in namespace std

Jan.Sommer at dlr.de Jan.Sommer at dlr.de
Wed Jan 11 09:43:49 UTC 2023


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);
}




More information about the users mailing list