我在 c# 中包装 pjsip (C-lib)。
我的电话如下
var account = new pjsua_acc_config();
Accounts.pjsua_acc_config_default(account);
通过这个得到枢轴;
[DllImportAttribute("pjsua.dll", EntryPoint = "pjsua_acc_config_default", CallingConvention = CallingConvention.Cdecl, PreserveSig = true)]
public static extern void pjsua_acc_config_default([In, Out] pjsua_acc_config cfg);
映射到
PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
这里 *cfg 是 0x00a5e8a8
下一个电话是使用默认配置添加帐户,所以我打电话
int id = Constants.PJSUA_INVALID_ID;
Accounts.pjsua_acc_add(account, 1, ref id);
它通过这个被激活;
[DllImportAttribute("pjsua.dll", EntryPoint = "pjsua_acc_add", CallingConvention = CallingConvention.Cdecl, PreserveSig = true)]
public static extern int pjsua_acc_add([In, Out]pjsua_acc_config acc_cfg, int is_default, ref int p_acc_id);
映射到
PJ_DEF(pj_status_t) pjsua_acc_add( const pjsua_acc_config *cfg, int is_default, int *p_acc_id)
这里 *cfg 是 0x00a5e888,偏移 32 位。它们应该指向同一个地址,因为它是同一个对象。
Howerer,如果我改变这个
public static extern void pjsua_acc_config_default([In, Out] pjsua_acc_config cfg);
进入
public static extern void pjsua_acc_config_default([In, Out] pjsua_acc_config cfg, pjsua_acc_config dummy1, pjsua_acc_config dummy2);
地址对齐了,有人知道是什么原因造成的吗?