mac*_*nir 2 c# c++ calling-convention dllexport visual-studio-2008
鉴于以下C++代码未在函数声明中提及调用约定,导出函数的调用约定是Exported什么?我的猜测是cdecl的默认值.
extern "C"
{
__declspec (dllexport) bool Exported(int parm);
}
Run Code Online (Sandbox Code Playgroud)
我从托管代码中调用这个函数,使用LoadLibrary,GetProcAddress和Marshal.GetDelegateForFunctionPointer.我可以使用不同的UnmanagedFunctionPointer属性值来装饰我的委托定义,它们似乎都可以工作.
默认调用约定是cdecl.请注意,__ declspec(dllexport)对调用约定没有影响.
可以在代码中或通过编译器选项指定调用约定.我不建议使用编译器选项,它有点太模糊了.在代码中明确表示,然后任何读取的人都知道使用了什么约定.
请注意,对于64位Windows代码,所有调用约定都是等效的,可以解释您所看到的内容.