문제

I must be missing something. Even the simplest test program using libgc fails. Any clues?

$ 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

I'm using libgc version 1 installed with macports.

도움이 되었습니까?

해결책

Apparently I need to call GC_INIT to make libgc work on Mac OS X, so my test program would be:

#include <gc/gc.h>

int main(void)
{
    char *s;

    GC_INIT();
    s = GC_MALLOC(1);
    return 0;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top