How do I make libgc work in Mac OS X?

613 views Asked by At

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.

1

There are 1 answers

0
August Karlstrom On BEST ANSWER

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;
}