简体   繁体   English

g ++:错误:“ pow”没有依赖模板参数的参数,因此“ pow”的声明必须可用[-fpermissive]

[英]g++: error: there are no arguments to 'pow' that depend on a template parameter, so a declaration of 'pow' must be available [-fpermissive]

This code compiled properly on Visual Studio 2010 on Windows, but I'm getting this error on Linux, g++. 这段代码可以在Windows的Visual Studio 2010上正确编译,但是在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] 错误:“ pow”没有依赖模板参数的参数,因此“ pow”的声明必须可用[-fpermissive]

Thank you. 谢谢。

您需要#include <cmath>并在数学库中使用-lm链接(在某些系统上)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:“at”没有依赖于模板参数的参数,因此at的声明必须可用 - error: there are no arguments to 'at' that depend on a template parameter, so a declaration of at must be available g ++模板参数错误 - g++ template parameter error 使用g ++从g ++和gfortran链接.o文件时出现“ __gfortran_pow_c8_i4”错误 - “__gfortran_pow_c8_i4” error when linking .o files from g++ and gfortran using g++ 没有依赖于模板参数的参数 - There are no arguments that depend on a template parameter 使用g ++的decltype模板声明 - Template declaration of decltype with g++ 错误:'int pow(double, int)' 与之前的声明冲突 int pow(double a, int n) { - error: ‘int pow(double, int)’ conflicts with a previous declaration int pow(double a, int n) { g ++编译器错误:无法推断模板参数'_Funct' - g++ compiler error: couldn't deduce template parameter ‘_Funct’ 错误:“static_assert”没有依赖于模板参数的参数 - Error: there are no arguments to 'static_assert' that depend on a template parameter 如何解决“没有依赖模板参数的&#39;glGenVertexArrays&#39;参数……”在C ++中的错误 - How to fix 'there are no arguments to 'glGenVertexArrays' that depend on a template parameter …' error in c++ C ++错误:“没有&#39;setw&#39;参数依赖模板参数 - C++ Error: "There are no arguments to 'setw' that depend on a template parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM