CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Linked lists and pointers in structures

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hwstar



Joined: 15 May 2010
Posts: 10

View user's profile Send private message

Linked lists and pointers in structures
PostPosted: Sun Jun 20, 2010 2:37 pm     Reply with quote

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?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 21, 2010 1:43 pm     Reply with quote

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).
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 23, 2010 10:41 am     Reply with quote

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.
hwstar



Joined: 15 May 2010
Posts: 10

View user's profile Send private message

PostPosted: Wed Jun 23, 2010 7:39 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group