This code compiled properly on Visual Studio 2010 on Windows, but I’m getting this error on Linux, g++. Could anyone please explain how to fix this?
int bits;
T scale;
std::vector<U> TwoPowers;
U cropper;
template <typename T, typename U>
ConvertToBits<T,U>::ConvertToBits(int bits, T scale)
{
this->bits = bits;
this->scale = scale;
for(long i = 0; i < 64; i++)
{
TwoPowers.push_back(static_cast<U>(pow(2.,i))); //error appears here
}
cropper = 0;
for(int i = 0; i < bits; i++)
{
cropper += TwoPowers[i];
}
}
Error message:
error: there are no arguments to ‘pow’ that depend on a template parameter, so a declaration of ‘pow’ must be available [-fpermissive]
Thank you.
You need to
#include <cmath>and also link in the math library with-lm(on some systems).