What is the protocol for mallocing when programming on the PICMicro chips? I've got a line like this:
char *data_array;
data_array = (char *)malloc(4);
When I try to compile it, I get an error saying, "Error - could not find definition of symbol 'malloc' in file './CAN.o'."
I have already included stdlib.h and all of the other standard includes.
Memory allocation?
Memory allocation?
No trees were harmed in the posting of this message. However, a large number of electrons were terribly inconvenienced.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Memory allocation?
Hello
If you have enough free memory in your device then you could always define the array as a static size eg
char data_array[4];
or
static char data_array[4];
Some compilers do support the malloc function so you will need to find the correct compiler or library that supports the malloc statement.
All the malloc statement is doing is trying to find some free bytes in the memory. If your memory is large or still has room then you will not need to do this function.
If you have enough free memory in your device then you could always define the array as a static size eg
char data_array[4];
or
static char data_array[4];
Some compilers do support the malloc function so you will need to find the correct compiler or library that supports the malloc statement.
All the malloc statement is doing is trying to find some free bytes in the memory. If your memory is large or still has room then you will not need to do this function.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel