pic是否支持malloc free
我用了一块pic16系列做了一个是否支持malloc的实验,代码很简单
#include<stdlib.h>
void main(void)
{
int *p=(int *)malloc(sizeof(int ));
if(p!=NULL)
{
free(p);
}
}
但是编译出现如下错误:
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 147. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 85. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 113. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 115. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 116. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 117. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 118. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 119. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 126. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\malloc.c; 130. can't generate code for this expression
Error [712] C:\Program Files\HI-TECH Software\PICC\PRO\9.65\sources\memcpy.c; 22. can't generate code for this expression
Advisory[1] too many errors (11)
请高人指教?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回复 1# laomujiwd
malloc和free是需要作業系統支援才能調用的系統函數, pic單片機上如果使用了uC-OS這樣的嵌入式作業系統, 并且增加了記憶體管理模塊,也許能使用malloc吧