QMCPACK / miniqmc

QMCPACK miniapp: a simplified real space QMC code for algorithm development, performance portability testing, and computer science experiments
Other
27 stars 35 forks source link

Compilation Error: spline2/MultiBsplineData.cpp std::min/max/modf not found #33

Closed crtrott closed 7 years ago

crtrott commented 7 years ago

Getting this error after doing in /build :

cmake ../
make -j 48
In file included from /home/crtrott/MiniApps/miniQMC/src/spline2/MultiBsplineData.cpp:18:0:
/home/crtrott/MiniApps/miniQMC/src/spline2/MultiBsplineData.hpp: In static member function ‘static void qmcplusplus::SplineBound<T>::get(T, T&, int&, int)’:
/home/crtrott/MiniApps/miniQMC/src/spline2/MultiBsplineData.hpp:29:12: error: ‘modf’ is not a member of ‘std’
         dx=std::modf(x,&ipart);
            ^
/home/crtrott/MiniApps/miniQMC/src/spline2/MultiBsplineData.hpp:30:15: error: ‘min’ is not a member of ‘std’
         ind = std::min(std::max(int(0),static_cast<int>(ipart)),ng);
               ^
/home/crtrott/MiniApps/miniQMC/src/spline2/MultiBsplineData.hpp:30:24: error: ‘max’ is not a member of ‘std’
         ind = std::min(std::max(int(0),static_cast<int>(ipart)),ng);
                        ^
make[2]: *** [src/CMakeFiles/qmcutil.dir/spline2/MultiBsplineData.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

This is with GCC 5.3.0. Adding the following before any of the other includes in MultiBsplineData.cpp fixes this:

#include<cmath>
#include<algorithm>

Adding these includes after the other ones does not fix it. This probably means that "math.h" gets included somewhere. I couldn't find it explicitly, but there might be an indirect inclusion. Including "math.h" sometimes prevents inclusion of later on, and only is guaranteed to have modf in the std namespace.

markdewing commented 7 years ago

I think PR #32 fixes this compilation issue.

crtrott commented 7 years ago

Oh you are right, that thing came in just after I tried all of this.