GoString与char*的差别
首先是golang导出dll头文件关于GoString的定义
typedef struct {
const char *p; ptrdiff_t n; } _GoString_;
typedef _GoString_ GoString;
主要是这两句,定义了GoString类型,写了个dll,然后直接在c中gcc使用dll和c源码进行编译,其中有一句:
printf("%s",goString.p);
其中goString为go语言中返回的string类型映射到c语言就是GoString类型,看似没错,也可以运行,就是运行的时候控制台打印了了一堆:
lost mcachemSpanManualmswsock.dllruntime: P runtime: p scheddetailsecur32.dllshell32.dll