A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
I have writed a simple program like this:
/* ******************************* */
#include <stdlib.h>
void main(void) { unsigned char *ptr; ptr = (unsigned char *) malloc(sizeof(unsigned char)); free(ptr); } /* ***************************** */
This just used to test how to use malloc() and free() in PICC.But after
compiled,some error message appear:
Error[000] : undefined symbols:
Error[000] : _free (D:\MPLAB IDE\PICproject\Test\test.obj) Error[000] : _malloc (D:\MPLAB IDE\PICproject\Test\test.obj) I have doubt in why these error message appear.How to do
dynamic memory's program such use malloc() and free() in PICC?
Best regards,
Bruce .J Sam |
|
|
|
You need to include "STDLIBM.H" to use those functions. The compiler is giving those errors because it doesn't know what those two functions are without STDLIBM.H included. --- In , "Bruce.J Sam" <persevreman@y...> wrote: > I have writed a simple program like this: > /* ******************************* */ > #include <stdlib.h> > > void main(void) > { > unsigned char *ptr; > > ptr = (unsigned char *) malloc(sizeof(unsigned char)); > free(ptr); > } > /* ***************************** */ > This just used to test how to use malloc() and free() in PICC.But after compiled,some error message appear: > Error[000] : undefined symbols: > Error[000] : _free (D:\MPLAB IDE\PICproject\Test\test.obj) > Error[000] : _malloc (D:\MPLAB IDE\PICproject\Test\test.obj) > I have doubt in why these error message appear.How to do dynamic memory's program such use malloc() and free() in PICC? > Best regards, > Bruce .J Sam > > --------------------------------- |
|
|
|
Thanks john,
But I couldn't found
STDLIBM.H in the installation directory of the picc.Are there other method to
solve?
Thanks again,
Bruce .J Sam.
john <j...@yahoo.com> wrote: You need to include "STDLIBM.H" to use those functions. The compiler |
|
|
|
Never mind about the STDLIBM.H that's for CCS's compiler, Hi-tech PICC has a malloc.c in its sources directory you would need to add. The malloc.c file has the free() and malloc() functions in it. -John --- In , "Bruce.J Sam" <persevreman@y...> wrote: > Thanks john, > But I couldn't found STDLIBM.H in the installation directory of the picc.Are there other method to solve? > Thanks again, > Bruce .J Sam. > john <j_funk1425@y...> wrote: > You need to include "STDLIBM.H" to use those functions. The compiler > is giving those errors because it doesn't know what those two > functions are without STDLIBM.H included. > > --- In , "Bruce.J Sam" <persevreman@y...> > wrote: > > I have writed a simple program like this: > > /* ******************************* */ > > #include <stdlib.h> > > > > void main(void) > > { > > unsigned char *ptr; > > > > ptr = (unsigned char *) malloc(sizeof(unsigned char)); > > free(ptr); > > } > > /* ***************************** */ > > This just used to test how to use malloc() and free() in PICC.But > after compiled,some error message appear: > > Error[000] : undefined symbols: > > Error[000] : _free (D:\MPLAB IDE\PICproject\Test\test.obj) > > Error[000] : _malloc (D:\MPLAB IDE\PICproject\Test\test.obj) > > I have doubt in why these error message appear.How to do > dynamic memory's program such use malloc() and free() in PICC? > > Best regards, > > Bruce .J Sam > --------------------------------- |