[Gc] GC_MALLOC doesn't compile..

Renaud Dubois renaud.dubois at gmail.com
Thu Mar 9 14:05:51 PST 2006


Hi,

I'm writing a compilation option to add the C garbage collector in my
program:
/* for the garbage collector */
#ifdef GARBAGE_COLLECTOR
#include "gc.h"
#define malloc(n)               GC_MALLOC(n)
#endif



I have set the GC_INIT in the header of the main().

int main(int argc, char **argv){
        int register i = 0;
        int fdcom;

        GC_INIT();


And for the "free()":

        /* free dynamic memory */
#ifndef GARBAGE_COLLECTOR
        free(tab_flow);
#endif


But when i try to compile, I have the following error:
gcc -I/usr/local/include/ -DDEBUG -DGARBAGE_COLLECTOR -O2 -march=i486
-Wall   -o module1 module1.o
module1.o: In function `initialisation_tab_flow_struct':
module1.c:(.text+0x3ad): undefined reference to `GC_malloc'
collect2: ld returned 1 exit status
make: *** [module1] Error 1

"initialisation_tab_flow_struct" is a small function where I do a malloc
call:

       if((tab_flow = malloc(number * sizeof(struct flow))) == NULL){
                perror_time("Memory allocation failed !\n");
                exit(EXIT_FAILURE);
        }

Thank you for your help..

Yours faithfully,

Renaud Dubois
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20060309/a283415c/attachment.htm


More information about the Gc mailing list