Question

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.

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top