【发布时间】:2011-08-24 21:24:54
【问题描述】:
typedef bool (*my_function_f)(int, double);
typedef bool (__stdcall *my_function_f2)(int, double);
// ^^^^^^^^^
template<class F> class TFunction;
template<class R, class T0, class T1>
class TFunction<R(*)(T0,T1)>
{
typedef R (*func_type)(T0,T1);
};
int main()
{
TFunction<my_function_f> t1; // works on x64 and win32
TFunction<my_function_f2> t2; // works on x64 and doesn't work on win32
return 0;
}
上面的代码在 Visual C++ 2010 中给了我以下错误:
1>e:\project\orwell\head\multimapwizard\trunk\externals.cpp(49): error C2079: 't2' uses undefined class 'Externals::TFunction<F>'
1> with
1> [
1> F=Externals::my_function_f2
1> ]
正如您所看到的 __stdcall 修饰符的问题。这是编译器的bug吗?
【问题讨论】:
-
__stdcall: “在安腾处理器系列 (IPF) 和 x64 处理器上,__stdcall 被编译器接受并忽略”,我猜这就是它在 64 位上工作的原因。
-
@sehe 他不是已经在使用那个语法了吗?
标签: c++ templates template-specialization stdcall