This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

undefined reference to `init_mempool

i am using Keil uVision3 + ADUC7026, i am trying to allocate

#include <ADuC7026.h>
#include "stdio.h"
#include "stdlib.h"

unsigned char memory_pool[0x400];
int main (void) {
int *i;
init_mempool (memory_pool, sizeof(memory_pool));
i = malloc(sizeof(int));
}

warning: implicit declaration of function 'init_mempool'
..........
error: undefined reference to 'init_mempool'

can someone help me ,why can't find init_mempool? "Do not use Standart Libriries" is uncheckt. and the system can find malloc.

thanks

Parents
  • The compiler warning ("implicit declaration") is because you have not supplied a prototype for the function. Usually this would come from a header file. It is not a standard C function, so stdlib.h won't do.

    As for the linker error ("undefined reference"), did you build and link init_mem.c with the rest of your program? This function is optional, since so many 8051 systems do without malloc(), and there's no need to have it taking up space in them all.

Reply
  • The compiler warning ("implicit declaration") is because you have not supplied a prototype for the function. Usually this would come from a header file. It is not a standard C function, so stdlib.h won't do.

    As for the linker error ("undefined reference"), did you build and link init_mem.c with the rest of your program? This function is optional, since so many 8051 systems do without malloc(), and there's no need to have it taking up space in them all.

Children