C静态模板函数导致armcc编译错误(304)
发布时间:2020-12-16 05:04:40 所属栏目:百科 来源:网络整理
导读:我已经在VS10和armcc4.1 [Build 561]上测试了以下代码的编译.函数depth1()和depth2()都在VS上编译,但是armcc只会编译depth1(),同时为depth2()提供错误304(没有匹配参数列表的实例).当foo和bar是非静态的时,它也会在armcc上编译得很好. 我很乐意明白为什么. t
我已经在VS10和armcc4.1 [Build 561]上测试了以下代码的编译.函数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); } 解决方法
根据上面的评论:这似乎是armcc 4.1中的一个错误.
如果您的雇主与ARM签订了支持合同,您可以在此处提出ARM支持问题:http://www.arm.com/support/obtaining-support/index.php(单击“开发工具”选项卡,然后选择蓝色“提升支持案例”按钮). 至于解决方法,你可以试试 >重新排列源文件中foo和bar的定义;和/或 template int foo(int arg); // or,if you like this style better,template int foo<int>(int arg); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |