当前位置:网站首页>开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
2022-07-07 21:48:00 【TSINGSEE】
在EasyGBS平台功能的开发与测试过程中,我们在go中加上C.free释放内存,出现下图报错:“could not determine kind of name for C.free”(编译失败)。

以下代码为加上C.free函数后,导致编译失败:

在EasyGBS同个项目中,其他的go文件也有C.free这样的方式释放内存函数。在编译可执行文件时,并没有出现编译错误。
所以在这里,我立马联想到可能是某个C的头文件没有加进去。因为在go中写C程序,不会有错误提示。所以这样就导致写出了错误,但是不知道。只有到编译成可执行程序时才会报错。
那么针对上述情况,对比两个go中C的头文件,最终找到#include <stdlib.h>头文件的引用。
cgo中C.free可以与#include <stdlib.h>一起使用,参考如下:

作为一家起源于EasyDarwin开源框架的技术型企业,在开发过程中,我们也乐于和所有的技术开发爱好者们一起交流代码技术、分享开发经验,为大家提供一些小小的参考。

随着AI技术的不断发展和落地应用,我们也逐渐在平台中融入人工智能检测及分析技术,例如人脸检测、人脸识别、人流量统计、车辆检测、车牌识别、轨迹跟踪、行为识别等。
目前我们基于EasyCVR平台和AI安全生产摄像机,推出了可应用在企业安全生产场景中的视频+AI解决方案。其中,AI安全生产摄像机采用了全新嵌入式多算法框架,内置多种AI算法,可根据摄像头配置选择算法,除了安全帽检测,还包括烟火检测、室内通道堵塞检测、离岗睡岗检测、周界入侵检测、室外消防通道占压检测等。感兴趣的用户可以前往演示平台进行体验或部署测试。
边栏推荐
- 苹果在iOS 16中通过'虚拟卡'安全功能进一步进军金融领域
- Variables and constants
- Quick sort (diagram +c code)
- Debezium series: support the use of variables in the Kill Command
- php 获取图片信息的方法
- GBU1510-ASEMI电源专用15A整流桥GBU1510
- C # Development -- pit encountered in JS intermodulation
- Record layoutrebuild Forcerebuildlayoutimmediate does not take effect
- 面试百问:如何测试App性能?
- LeetCode206. Reverse linked list [double pointer and recursion]
猜你喜欢

微生物健康网,如何恢复微生物群落

Visual design form QT designer design gui single form program

LeetCode203. Remove linked list elements

「开源摘星计划」Loki实现Harbor日志的高效管理

Sword finger offer 27 Image of binary tree

vite Unrestricted file system access to

UWA Q & a collection

Microbial health network, how to restore microbial communities

Early childhood education industry of "screwing bar": trillion market, difficult to be a giant

Leetcode1984. Minimum difference in student scores
随机推荐
Line test - graphic reasoning -5- one stroke class
Unity与WebGL的相爱相杀
Line test - graphic reasoning - 6 - similar graphic classes
Nx10.0 installation tutorial
Antd date component appears in English
Revit secondary development - get the project file path
IP网络主动测评系统——X-Vision
Robot autonomous exploration series papers environment code
行测-图形推理-1-汉字类
Quick sort (diagram +c code)
Microbial health network, how to restore microbial communities
行测-图形推理-5-一笔画类
Aspose. Word operation word document (I)
Leetcode1984. Minimum difference in student scores
Xcode modifies the default background image of launchscreen and still displays the original image
Understand the autograd package in pytorch
Form组件常用校验规则-2(持续更新中~)
CTF exercise
Line test - graphic reasoning - 2 - black and white lattice class
Record problems fgui tween animation will be inexplicably killed