我已经在VS10和armcc4.1build561上测试了以下代码的编译。函数depth1()和depth2()都在VS上编译,但是armcc将只编译depth1(),同时为depth2()给出错误304 (没有与参数列表匹配的实例)。当foo和bar是非静态的时,它在armcc上也能很好地编译。
我很乐意理解其中的原因。
template <class T>
static T foo(T arg)
{
return arg*5;
}
template <class T>
static T bar(T arg)
{
return foo<T>(arg);
}
void depth2()
{
int i = 12;
i = bar<int>(i);
}
void depth1()
{
int i = 12;
i = foo<int>(i);
}发布于 2013-06-19 07:32:24
根据上面的评论:这似乎是armcc 4.1中的一个错误。
如果您的雇主与ARM签订了支持合同,您可以在此处向ARM提出支持问题:http://www.arm.com/support/obtaining-support/index.php (单击“开发工具”选项卡,然后单击蓝色的大按钮“提出支持案例”)。
至于变通方法,您可以尝试
foo和bar的定义;在其定义之前为foo和/或bar添加正向声明;和/或foo<int>的显式实例化,如下所示:模板int foo(int arg);//或者,如果您更喜欢这种风格,模板int foo(int arg);
https://stackoverflow.com/questions/16394917
复制相似问题