亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 cgo 包裝 <dispatch/dispatch.h> 時構建錯誤

使用 cgo 包裝 <dispatch/dispatch.h> 時構建錯誤

Go
達令說 2021-06-17 22:21:06
我正在嘗試使用 XPC、GCD 并繼續運行,但是當我的代碼無法編譯時出現以下錯誤消息(我不明白),我很快就遇到了問題:main(__DATA/__const): unexpected reloc for dynamic symbol _NSConcreteGlobalBlock main(__DATA/__const): unhandled relocation for _NSConcreteGlobalBlock (type 28 rtype 120)我正在使用go build以下代碼進行編譯:main.gopackage main/*#include <xpc/xpc.h>#include "wrapper.h"*/import "C"import (    "fmt")//export HandleXPCEventfunc HandleXPCEvent(event C.xpc_object_t) {    fmt.Println("Event was handled")}func main() {    name := C.CString("com.example.xpc")    queue := C.dispatch_queue_create(name, nil)    conn := C.xpc_connection_create(name, queue)    C.set_event_handler(conn)    //C.xpc_connection_resume(conn)}包裝器.h#ifndef _WRAPPER_H_#define _WRAPPER_H_#include <stdlib.h>#include <stdio.h>#include <xpc/xpc.h>xpc_connection_t connect( char* name);void set_event_handler(xpc_connection_t connection);#endif包裝器#include "wrapper.h"#include <dispatch/dispatch.h>extern void HandleXPCEvent(xpc_object_t);xpc_connection_t connect( char* name) {    dispatch_queue_t queue = dispatch_queue_create(name,0);    return xpc_connection_create(name,queue);}void set_event_handler(xpc_connection_t connection) {    xpc_connection_set_event_handler(connection, ^(xpc_object_t event) {        xpc_retain(event);        // Call Go function        HandleXPCEvent(event);    });}我是不是做錯了什么?這是某種 go 錯誤還是如何修復?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 283 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號