microchip dspic33 malloc函数使用
1. 用法
#include <stdlib.h> //for maloc, free etc
#include <string.h> //for memset
void malloc_free_test(void)
{
long *i;
if ((i = (long *)malloc(50 * sizeof(long))) == NULL)
printf("Cannot allocate memory\n");
else {
printf("Memory allocated[i=%ld]\n", i);
free(i);
printf("Memory freed\n");
}
}
2. 编译报错
elf-ld.exe Error: A heap is required, but has not been specified
3. 解决办法
需要定义heap