我一定漏掉了什么。即使是使用libgc的最简单的测试程序也会失败。有什么线索吗?
$ cat test.c
#include <gc/gc.h>
int main(void)
{
char *s;
s = GC_MALLOC(1);
return 0;
}
$ cc -ansi -pedantic -Wall -I/opt/local/include -L/opt/local/lib -o test test.c -lgc
$ ./test
Segmentation fault我使用的是安装了macports的libgc版本1。
发布于 2012-05-27 22:24:54
显然,我需要调用GC_INIT来让libgc在Mac上工作,所以我的测试程序是:
#include <gc/gc.h>
int main(void)
{
char *s;
GC_INIT();
s = GC_MALLOC(1);
return 0;
}https://stackoverflow.com/questions/10773973
复制相似问题