doulangbizhan5160 2019-09-05 04:58 采纳率: 100%
浏览 132

GoLang和CPP之间的交叉通信映射时出现内存错误

I'm trying to pass a Unordered_Map from Cpp to GoLang. I have currently created a dll from GoLang which contains a method which accepts a Map as input and initialize it. My assumption is that in GoLang Map is passed as reference so I'm not returning anything.

    //GoLang CODE
    func InitializeMap(m map[*C.char]*C.char) { 
        ctr1 := C.CString("Anand")
        ctr2 := C.CString("1")
        m[ctr1] = ctr2   // Memory error is pointing at this line.
     }

         // CPP 
         std::unordered_map<char *,char *> mapInstance;
         InitializeMap(&mapInstance);

        // Header
        typedef void *GoMap;
        extern void InitializeMap(GoMap p0);

The error thrown is :

unexpected fault address 0x18dda4d0080 fatal error: fault [signal 0xc0000005 code=0x0 addr=0x18dda4d0080 pc=0x6de902e3]

Please Help me in right direction.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题