I have tested compilation of the following code on both VS10 and armcc4.1 [Build 561]. Both functions depth1() and depth2() compile on VS, however armcc will only compile depth1() while giving an Error 304 (no instance of matches the argument list) for depth2(). When foo and bar are non-static, it compiles fine on armcc as well.
I'd be happy to understand why.
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);
}
Per the comments above: This appears to be a bug in armcc 4.1.
If your employer has a support contract with ARM, you can raise a support issue with ARM here: http://www.arm.com/support/obtaining-support/index.php (click the "Development Tools" tab and then the big blue "Raise a Support Case" button).
As for workarounds, you might try
foo
and bar
in the source file; and/orfoo
and/or bar
somewhere prior to its definition; and/oradding an explicit instantiation of foo<int>
somewhere after its declaration, like this:
template int foo(int arg);
// or, if you like this style better,
template int foo<int>(int arg);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With