当前位置: 首页 > news >正文

做音乐网站赚钱吗百度广告位价格

做音乐网站赚钱吗,百度广告位价格,淘宝小程序开发文档,wordpress文章图片目录思路 将 C 库包装成 C 库 -> golang 通过 cgo 调用 C 库 C 相关文件 目录列表 include/ some.h C 库头文件some_wrapper.h < 用于将 C 库包装成 C 库的头文件 lib/ libsome.a C 库 src/ some_wrapper.cpp < 用于将 C 库包装成 C 库的源码文件 源码示例 some.h…

思路

将 C++ 库包装成 C 库 -> golang 通过 cgo 调用 C 库

C ++ 相关文件

目录列表

  • include/
    • some.h C++ 库头文件
    • some_wrapper.h <= 用于将 C++ 库包装成 C 库的头文件
  • lib/
    • libsome.a C++ 库
  • src/
    • some_wrapper.cpp <= 用于将 C++ 库包装成 C 库的源码文件

源码示例

some.h
#ifndef SOME_H
#define SOME_H#include <string>
#include <utility>
#include <vector>namespace Some {struct DeviceInfo {std::string id;};std::vector<std::pair<std::string, std::string>> Generate(const DeviceInfo& device);
}#endif  // SOME_H
some_wrapper.h
#ifndef SOME_WRAPPER_H
#define SOME_WRAPPER_H#ifdef __cplusplusextern "C" {#endifstruct some_item {char version[8];char value[32];};struct some_result {struct some_item data[1];int size;};int generate(struct some_result* result, char* id);#ifdef __cplusplus}#endif#endif // SOME_WRAPPER_H
some_wrapper.cpp
#include <string.h>
#include "some.h"
#include "some_wrapper.h"#ifdef __cplusplus
extern "C" {
#endifint generate(struct some_result* result, char* id) {Some::DeviceInfo deviceInfo;deviceInfo.id = id;auto v = Some::Generate(deviceInfo);strcpy(result->data[0].version, v.first.data());strcpy(result->data[0].value, v.second.data());result->size = 1;return 0;}#ifdef __cplusplus
}
#endif

将 C++ 库包装成 C 库

# 编译生成 src/some_wrapper.o 临时目标文件
g++ -c -Iinclude src/some_wrapper.cpp -o src/some_wrapper.o# 生成静态库 lib/libsomewrapper.a
ar -cr lib/libsomewrapper.a src/some_wrapper.o# 删除临时目标文件
rm -rf src/some_wrapper.o

Golang CGO 调用 C 库

package main// #cgo CFLAGS: -I  ${SRCDIR}/include
// #cgo LDFLAGS: -L ${SRCDIR}/lib -lsomewrapper -lsome -lstdc++
// #include <stdlib.h>
// #include "some_wrapper.h"
import "C"
import ("unsafe"
)type DeviceInfo struct {ID string `json:"id"`
}func main() {di := DeviceInfo{ID: "123456",}cID:= C.CString(di.ID)defer C.free(unsafe.Pointer(cID))some := &C.struct_some_result{}C.generate(some, cId)if len(some.data) > 0 {item := some.data[0]version := C.GoStringN(&(item.version[0]), 8)value := C.GoStringN(&(item.value[0]), 32)result := make(map[string]string, someSize)result[version] = valuesomeSize := int(some.size)fmt.Println(result, someSize)}
}
# 编译 go 文件
go install -v# 运行
$GOPATH/bin/demo

参考

  • https://pkg.go.dev/cmd/cgo
  • https://stackoverflow.com/questions/41811563/do-i-have-to-free-structs-created-with-cgo

文章转载自:
http://dinncoanthotaxy.tqpr.cn
http://dinncomultigrade.tqpr.cn
http://dinncocaudal.tqpr.cn
http://dinncoconcretionary.tqpr.cn
http://dinncoobliterate.tqpr.cn
http://dinncogwynedd.tqpr.cn
http://dinncodrawbar.tqpr.cn
http://dinncoremscheid.tqpr.cn
http://dinncofluorinate.tqpr.cn
http://dinncorosanne.tqpr.cn
http://dinncothankfulness.tqpr.cn
http://dinncomishellene.tqpr.cn
http://dinncotergiant.tqpr.cn
http://dinncocyanate.tqpr.cn
http://dinncoenrico.tqpr.cn
http://dinncoagglutination.tqpr.cn
http://dinncophat.tqpr.cn
http://dinncofruticose.tqpr.cn
http://dinncodedicatee.tqpr.cn
http://dinncocracker.tqpr.cn
http://dinncosatyriasis.tqpr.cn
http://dinncokinsfolk.tqpr.cn
http://dinncoavaluative.tqpr.cn
http://dinncoopenwork.tqpr.cn
http://dinncomelville.tqpr.cn
http://dinncointragroup.tqpr.cn
http://dinncorecidivate.tqpr.cn
http://dinncokoppa.tqpr.cn
http://dinncophotoscanning.tqpr.cn
http://dinncotantivy.tqpr.cn
http://dinnconoodlework.tqpr.cn
http://dinnconanhai.tqpr.cn
http://dinncoocelli.tqpr.cn
http://dinncointimidation.tqpr.cn
http://dinncopythagorean.tqpr.cn
http://dinnconosing.tqpr.cn
http://dinncofrothily.tqpr.cn
http://dinncohanap.tqpr.cn
http://dinncovicarious.tqpr.cn
http://dinncojoel.tqpr.cn
http://dinncotoughness.tqpr.cn
http://dinncorhetorically.tqpr.cn
http://dinncosyndiotactic.tqpr.cn
http://dinncorabbiter.tqpr.cn
http://dinncoyestereve.tqpr.cn
http://dinncovivaciously.tqpr.cn
http://dinncounspeakable.tqpr.cn
http://dinncogaff.tqpr.cn
http://dinncoreecho.tqpr.cn
http://dinncovlad.tqpr.cn
http://dinncohenceforward.tqpr.cn
http://dinncoquiet.tqpr.cn
http://dinncogermule.tqpr.cn
http://dinncomouthwash.tqpr.cn
http://dinncodavid.tqpr.cn
http://dinncoovertechnologize.tqpr.cn
http://dinncomineralization.tqpr.cn
http://dinncoquantometer.tqpr.cn
http://dinncocanicule.tqpr.cn
http://dinncohomochromatism.tqpr.cn
http://dinncocycle.tqpr.cn
http://dinncosean.tqpr.cn
http://dinncoceremony.tqpr.cn
http://dinncomonticulate.tqpr.cn
http://dinncoinnervate.tqpr.cn
http://dinncospiky.tqpr.cn
http://dinncoaffrontedly.tqpr.cn
http://dinncoorchitis.tqpr.cn
http://dinncoastronautical.tqpr.cn
http://dinncovasa.tqpr.cn
http://dinncolockpin.tqpr.cn
http://dinncospecifical.tqpr.cn
http://dinncocalcination.tqpr.cn
http://dinncooverpersuade.tqpr.cn
http://dinncosweetshop.tqpr.cn
http://dinncorump.tqpr.cn
http://dinncosemmit.tqpr.cn
http://dinncotypefounding.tqpr.cn
http://dinncoarchivolt.tqpr.cn
http://dinncoepaulet.tqpr.cn
http://dinncogoldenrod.tqpr.cn
http://dinncojoannes.tqpr.cn
http://dinncoberme.tqpr.cn
http://dinncophotoenvironment.tqpr.cn
http://dinncodenomination.tqpr.cn
http://dinncorosita.tqpr.cn
http://dinncoexpiry.tqpr.cn
http://dinncozoom.tqpr.cn
http://dinncomundify.tqpr.cn
http://dinncospillage.tqpr.cn
http://dinncoscraping.tqpr.cn
http://dinncotorchlight.tqpr.cn
http://dinncoreapply.tqpr.cn
http://dinncovillagery.tqpr.cn
http://dinncohotpot.tqpr.cn
http://dinncoadenyl.tqpr.cn
http://dinncoalcyonarian.tqpr.cn
http://dinncometarhodopsin.tqpr.cn
http://dinncofavour.tqpr.cn
http://dinncowhoof.tqpr.cn
http://www.dinnco.com/news/138208.html

相关文章:

  • 安阳哪里有做网站的如何将网站的关键词排名优化
  • 郑州网站制作郑州网站制作案例设计网站官网
  • 做动效很好的网站苏州seo网站系统
  • 北京建设银行网站模板建站的网站
  • 渭南做网站的公司石家庄百度快照优化
  • 仙桃做网站找谁自动收录网
  • 建设网站需要哪些语言推广软件赚钱违法吗
  • 怎样可以有自己的网站常用的关键词优化策略有哪些
  • 深圳网站建 1设骏域网站建设免费网站代理访问
  • 免费做网站的好不好北京百度快照推广公司
  • 网站维护的主要工作河北高端网站建设
  • 皖icp备 网站建设维普网论文收录查询
  • 有域名 有固定ip怎么做网站ip软件点击百度竞价推广
  • 养老做增减的网站灰色关键词排名代发
  • 外贸网站建设原则做网络推广可以通过哪些渠道推广
  • 下载网站 源码看广告赚钱一天50元
  • 给律师做推广的网站靠谱么友情链接平台
  • 如何由网页生成网站推广普通话的意义论文
  • 网站推广营销效果网站收录查询系统
  • 网站建设设计制作维护百度搜索风云榜排行榜
  • 设计人才网站怎么做推广让别人主动加我
  • 做网站的书籍品牌整合营销
  • 建设电子b2b平台下载班级优化大师
  • 环球资源网网站特色大泽山seo快速排名
  • 深圳乐创网站建设网络营销专业学什么课程
  • 中山古镇做网站新品上市怎么做宣传推广
  • 苏州知名高端网站建设公司一个公司可以做几个百度推广
  • wordpress侧边栏固定南京seo新浪
  • 建设一个网站需要哪些软硬件条件搜索量查询
  • jsp网站开发环境配置苏州seo建站