View previous topic :: View next topic |
Author |
Message |
hwstar
Joined: 15 May 2010 Posts: 10
|
Linked lists and pointers in structures |
Posted: Sun Jun 20, 2010 2:37 pm |
|
|
I'm getting an error in the following code using the CCS compiler 4.108 (linux version):
Code: |
#include <16F1936.h>
#pragma device ADC=10 WRITE_EEPROM=NOINT
#pragma nolist
#include <stdlib.h>
#include <stdlibm.h>
#pragma list
#pragma fuses HS, PLL, WDT, PUT, NOLVP
#pragma use delay(clock=32Mhz, restart_wdt)
#pragma zero_ram
#pragma use fast_io(ALL)
#pragma priority INT_TIMER0, INT_RDA
#pragma use rs232(baud=9600,UART1, ERRORS)
#define B0RKED
typedef struct tmbtag
{
char *msgbuf;
struct tmbtag *next;
} tmb_t;
tmb_t *tmbhead;
#ifdef GOOD
void queue_telem( tmb_t *m)
{
tmb_t *lp;
if(!tmbhead)
tmbhead = m;
else{
lp = tmbhead;
while(1){ // Compiler bug workaround
tmb_t *n = lp->next;
if(n == NULL)
break;
lp = n;
}
lp->next = m;
}
}
#endif
#ifdef B0RKED
void queue_telem( tmb_t *m)
{
tmb_t *lp;
if(!tmbhead)
tmbhead = m;
else{
lp = tmbhead;
while(lp->next != NULL){ // Compile error
lp = lp->next;
}
lp->next = m;
}
}
#endif
main()
{
tmb_t tele;
queue_telem( &tele);
}
|
The B0RKED version of queue_telem() compiles with an error, and the GOOD version queue_telem() compiles without error. To me, both functions accomplish the same thing, but the B0RKED version is cleaner.
Does anybody see anything which isn't equivalent between the two functions? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 21, 2010 1:43 pm |
|
|
It compiles OK in vs. 4.107 (Windows compiler), but it fails in vs. 4.108
with this error message:
Code: |
Executing: "C:\Program Files\PICC\Ccsc.exe" +FM "pcm_test.c" +DF +LY -T -A +M -Z +Y=9 +EA -EW
*** Error 124 "pcm_test.c" Line 55(29,30): Structure field name required
1 Errors, 0 Warnings.
Skipping link step. Not all sources built successfully.
BUILD FAILED: Mon Jun 21 12:40:10 2010
|
So clearly CCS has done some change that caused the error.
I didn't investigate it any further than this. You could report it to CCS.
If you have vs. 4.107 you could rollback to that. Or you could request
4.107 from CCS if you deleted it off your hard drive by mistake.
These are some suggestions. (I don't have the Linux version of the compiler). |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 23, 2010 10:41 am |
|
|
It still fails to compile in vs. 4.108, but I just downloaded vs. 4.109 and
it's now fixed. It compiles OK in 4.109. |
|
![](templates/subSilver/images/spacer.gif) |
hwstar
Joined: 15 May 2010 Posts: 10
|
|
Posted: Wed Jun 23, 2010 7:39 pm |
|
|
Thanks for taking a look.
I'll continue to use the workaround for now. I will pay for a 1 yr. maintenance if I find something which can't be worked around. |
|
![](templates/subSilver/images/spacer.gif) |
|