谁能告诉我以下两行代码的完整含义?
typedef void DLLEXPORT __stdcall (*DLL_Inquiry) (char *cDriverName, int *iDriverType, int *iDriverBUS, int *iNumberOfChannel);
DLL_Inquiry DRV_PH_Inquiry;
我知道 DLLEXPORT
是从 DLL 导出函数,__stdcall
是 x86 参数传递约定。
但我仍然无法理解这两行的全部含义。可能是我对 typedef
中函数或函数指针的使用感到困惑。
最佳答案
DLL_Incuiry
是一个指向函数指针的类型定义,它接受参数 (char*, int*, int*, int*)
并且不返回任何值(返回类型 无效
)。该函数还使用 DLLEXPORT 和 __stdcall 定义的调用约定。
DRV_PH_Inquiry
是该类型的变量,因此如果您有函数 foo
:
void DLLEXPORT __stdcall foo (char *cDriverName, int *iDriverType, int *iDriverBUS, int *iNumberOfChannel);
然后你就可以做作业了:
DRV_PH_Inquiry = foo; // DRV_PH_Inquiry now points to the function foo
关于c++ - C 中的 typedef、DLLEXPORT、__stdcall 帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22909726/