µTasker Forum
µTasker Forum => µTasker general => Topic started by: alager on June 12, 2009, 09:18:41 PM
-
I'm trying to make a buffer that grows as the size of the data does, and so I'm trying a linked list. The code I have compiles and works fine in MSVC and the simulator, but CW won't compile it.
It says:Error : illegal implicit conversion from 'unsigned long **' to 'unsigned long *' my_uart.c line 245 fnAddNode(&pList, RXBuffer);
Error : illegal implicit conversion from 'unsigned long *' to 'unsigned long **' my_util.c line 107 pTmpNode = *pTmpNode;
I've following the examples from http://en.wikipedia.org/wiki/Linked_list#Language_support (http://en.wikipedia.org/wiki/Linked_list#Language_support)
Here is my code:
unsigned long *pList=NULL;
void fnProcessRx(CHAR *RXBuffer, QUEUE_TRANSFER length){
fnAddNode(&pList, RXBuffer); //this line fails in the compiler (line 245)
}
//take an array and allocate a chunk of ram for it on the heap
//then copy the array into the data section
//structure is an array: |ptr|string data|
void fnAddNode(unsigned long** pNode, CHAR * data){
unsigned long * pTmp;
unsigned long **pTmpNode;
pTmpNode = pNode;
pTmp = uMalloc(uStrlen(data)+1+4); //extra bytes added, one for the NULL string terminator and 4 for the address pointer
if (pTmp == NULL) {
//return NULL;
}
*pTmp=NULL; //make sure that the new pointer is NULL
uStrcpy((CHAR*)(pTmp+1),data); //copy the data into the new link node
//go to the end of the list to add
if (pTmpNode != NULL) {
while (*pTmpNode != NULL) {
pTmpNode = *pTmpNode; //this line fails to compile in CW
}
*pTmpNode = pTmp;
}else{
//the list appears to be empty
//*pNode = pTmp;
*pNode = pTmp;
}
}
If anyone has any pointers (no pun intended) that would be great!
Thanks,
Aaron
-
I think I got it figured out, I needed some explicit casts.
fnAddNode((unsigned long *)&pList, RXBuffer);
andpTmpNode = (unsigned long **)*pTmpNode;
This still works in the simulator and now CW compiles it just fine.
Aaron