就下面的代码而言,我有两个可能很简单的问题:
#include <windows.h>//IN and OUT prefixes are defined here
typedef int(__cdecl *FOO)(IN int input);
int my_int_func(IN int x) {
return x;
}
int main() {
int res = 0;
FOO foo = &my_int_func;
res = (*foo)(5);
return 0;
}代码实际上运行得无懈可击。以下是问题:
1) typedef行中的IN前缀是什么意思?前缀在windows.h头中定义。如果省略了头部,代码就会挂起。
2)如果我将__cdecl调用约定更改为__stdcall,编译器在&my_int_func下面加下划线并输出错误消息" error :无法使用类型为"int (*)(int x)“的值初始化类型为”FOO“的实体。我的问题是为什么?
我使用的是MS Visual Studio Ultimate 2013。
发布于 2014-11-05 18:42:38
https://stackoverflow.com/questions/26754370
复制相似问题